diff --git a/CMakeLists.txt b/CMakeLists.txt index 18f0dc69d7bb29dda4835c23347704e15be06d8b..0558d2011455be7bb71d95f66210afa4118481ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,58 @@ 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("models" "$ENV{TADAH_PATH}" DEVELOP_CORE_DIR) + set(FETCHCONTENT_SOURCE_DIR_TADAH.MODELS "${DEVELOP_MODELS_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})