Skip to content

Commit

Permalink
Update ConanHandle.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
traversebitree committed Feb 3, 2024
1 parent 7a70589 commit eeea8c3
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions cmake/ConanHandle.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
include_guard(GLOBAL)
set(ENV{CONAN_HOME} "${CMAKE_CURRENT_SOURCE_DIR}/.conan")
set(ENV{VIRTUAL_ENV} "$ENV{CONAN_HOME}/.venv")
set(Python3_FIND_VIRTUALENV ONLY)
set(_CONAN_BUILD_ROOT_PATH "$ENV{CONAN_HOME}/build")
find_package(Python3 COMPONENTS Interpreter REQUIRED)
cmake_path(GET Python3_EXECUTABLE PARENT_PATH _PYTHON_ROOT_PATH)
set(_PIP_SCRIPT_ROOT_PATH "${_PYTHON_ROOT_PATH}/Scripts")
find_program(_CONAN_EXEC "conan" HINTS "${_PIP_SCRIPT_ROOT_PATH}")
set(_PIP_BREAK_SYSTEM_PACKAGES "")
if("${CMAKE_HOST_SYSTEM_NAME}" MATCHES "Darwin")
set(_PIP_BREAK_SYSTEM_PACKAGES "--break-system-packages")
find_package(Python3 COMPONENTS Interpreter)
if(NOT Python3_EXECUTABLE)
set(Python3_FIND_VIRTUALENV STANDARD)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
execute_process(COMMAND ${Python3_EXECUTABLE} "-m" "venv" "$ENV{VIRTUAL_ENV}")
unset(Python3_EXECUTABLE)
set(Python3_FIND_VIRTUALENV ONLY)
find_package(Python3 COMPONENTS Interpreter REQUIRED)
endif()
find_program(_CONAN_EXEC "conan" HINTS "$ENV{VIRTUAL_ENV}/Scripts" NO_DEFAULT_PATH)
if(NOT EXISTS "${_CONAN_EXEC}")
execute_process(
COMMAND ${Python3_EXECUTABLE} "-m" "pip" "install" "conan" "--no-warn-script-location"
"${_PIP_BREAK_SYSTEM_PACKAGES}" COMMAND_ERROR_IS_FATAL LAST
COMMAND ${Python3_EXECUTABLE} "-m" "pip" "install" "conan" "--no-warn-script-location" COMMAND_ERROR_IS_FATAL LAST
)
find_program(_CONAN_EXEC "conan" HINTS "${_PIP_SCRIPT_ROOT_PATH}" REQUIRED)
find_program(_CONAN_EXEC "conan" HINTS "$ENV{VIRTUAL_ENV}/Scripts" REQUIRED)
endif()

set(_CONAN_PROFILE_FILE_PATH "$ENV{CONAN_HOME}/profiles/default")
if(NOT EXISTS "${_CONAN_PROFILE_FILE_PATH}")
execute_process(COMMAND ${_CONAN_EXEC} "profile" "detect" COMMAND_ERROR_IS_FATAL LAST)
Expand Down

0 comments on commit eeea8c3

Please sign in to comment.