forked from lthn/blockchain
Add Conan profile setup script and update Makefile for profile detection
This commit is contained in:
parent
eca04f4332
commit
c1f3b2e773
2 changed files with 43 additions and 5 deletions
6
Makefile
6
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
|
||||
|
|
|
|||
42
cmake/ConanProfileSetup.cmake
Normal file
42
cmake/ConanProfileSetup.cmake
Normal file
|
|
@ -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.")
|
||||
Loading…
Add table
Reference in a new issue