From e11b45799e1145474d8dbbe5d544f14aa3e53ec3 Mon Sep 17 00:00:00 2001 From: mkirsz <s1351949@sms.ed.ac.uk> Date: Sun, 16 Feb 2025 17:10:11 +0000 Subject: [PATCH] Added develop mode --- CMakeLists.txt | 56 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67aec32..e0faae3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,59 @@ if (BUILD_SHARED_LIBS) endif("${isSystemDir}" STREQUAL "-1") endif() + +# Set default build type +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Release) +endif() + +string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) +if (CMAKE_BUILD_TYPE STREQUAL "DEVELOP") +if(NOT DEFINED ENV{TADAH_PATH}) + message(FATAL_ERROR "TADAH_PATH system variable is undefined for the ${CMAKE_BUILD_TYPE} build") +endif() + function(find_directory_case_insensitive target_name search_dir result_var) + execute_process( + COMMAND find "${search_dir}" -maxdepth 1 -type d -iname "${target_name}" + OUTPUT_VARIABLE found_dir + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(found_dir) + set(${result_var} "${found_dir}" PARENT_SCOPE) + message("${TADAH} Develop build: Found directory: ${found_dir}") + else() + set(${result_var} "" PARENT_SCOPE) + message("${TADAH} Develop build: Directory not found.") + endif() + endfunction() + find_directory_case_insensitive("core" "$ENV{TADAH_PATH}" DEVELOP_CORE_DIR) + set(FETCHCONTENT_SOURCE_DIR_TADAH.CORE "${DEVELOP_CORE_DIR}") +endif() + + +# Check is build supported +string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE) +if (CMAKE_BUILD_TYPE STREQUAL "DEBUG" + OR + CMAKE_BUILD_TYPE STREQUAL "RELEASE" + OR + CMAKE_BUILD_TYPE STREQUAL "PROFILE" + OR + CMAKE_BUILD_TYPE STREQUAL "DEVELOP" +) + message(STATUS "${TADAH} Build type: ${CMAKE_BUILD_TYPE}.") +else() + message(FATAL_ERROR " + Selected build type is not supported: ${CMAKE_BUILD_TYPE}. + Supported build types: Release, Debug, Profile Develop" + ) +endif() + +# Update the documentation string of CMAKE_BUILD_TYPE for GUIs +set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING + "Choose the type of build, options are: None Debug Release Profile." + FORCE) + include(FetchContent) if(DEFINED ENV{CI_COMMIT_REF_NAME}) @@ -61,9 +114,6 @@ FetchContent_Declare( Tadah.CORE GIT_REPOSITORY https://git.ecdf.ed.ac.uk/tadah/core.git GIT_TAG origin/${GIT_BRANCH} - #SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../CORE - #PATCH_COMMAND mkdir -p ${BUILD_DIR_NAME} - #BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../CORE/${BUILD_DIR_NAME} ) FetchContent_MakeAvailable(Tadah.CORE) -- GitLab