diff --git a/Makefile b/Makefile index f4958f60..8bd8fa9b 100644 --- a/Makefile +++ b/Makefile @@ -102,11 +102,7 @@ get-conan: cmake -P cmake/GetConan.cmake conan-profile-detect: get-conan - @if [ ! -f "$(DEFAULT_CONAN_PROFILE)" ]; then \ - echo "Default conan profile not found. Detecting a new one..."; \ - CONAN_HOME=$(CONAN_CACHE) $(CONAN_EXECUTABLE) profile detect --name=default --force; \ - fi - + cmake -P cmake/ConanProfileSetup.cmake # Rule for each profile $(PROFILES): conan-profile-detect diff --git a/cmake/ConanProfileSetup.cmake b/cmake/ConanProfileSetup.cmake new file mode 100644 index 00000000..1291b669 --- /dev/null +++ b/cmake/ConanProfileSetup.cmake @@ -0,0 +1,42 @@ +# Use the CONAN_HOME from the environment, or default to a local directory. +if(NOT DEFINED ENV{CONAN_HOME}) + set(CONAN_HOME "${CMAKE_SOURCE_DIR}/build/sdk") + message(STATUS "CONAN_HOME not set, defaulting to: ${CONAN_HOME}") +else() + set(CONAN_HOME "$ENV{CONAN_HOME}") +endif() + +set(DEFAULT_PROFILE "${CONAN_HOME}/profiles/default") + + +if(NOT EXISTS "${DEFAULT_PROFILE}") + message(STATUS "Conan default profile not found. Detecting a new one...") + set(ENV{CONAN_HOME} "${CONAN_HOME}") + execute_process( + COMMAND "${CMAKE_SOURCE_DIR}/build/bin/conan" profile detect --name=default --force + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE return_code + ) + unset(ENV{CONAN_HOME}) + + if(NOT return_code EQUAL 0) + message(FATAL_ERROR "Conan profile detection failed with exit code: ${return_code}") + endif() +endif() + +message(STATUS "Appending custom settings to Conan default profile...") + +set(CUSTOM_SETTINGS " +compiler.cppstd=17 +") + +if(WIN32) + message(STATUS "Windows detected. Appending static runtime setting.") + string(APPEND CUSTOM_SETTINGS " +compiler.runtime=static +") +endif() + +file(APPEND "${DEFAULT_PROFILE}" "${CUSTOM_SETTINGS}") + +message(STATUS "Conan profile setup is complete.") \ No newline at end of file