Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function(detect_os OS OS_API_LEVEL OS_SDK OS_SUBSYSTEM OS_VERSION)
message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}")
set(${OS_SDK} ${_OS_SDK} PARENT_SCOPE)
endif()
if(DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
if(CONAN_USE_CMAKE_OSX_DEPLOYMENT_TARGET)
message(STATUS "CMake-Conan: cmake_osx_deployment_target=${CMAKE_OSX_DEPLOYMENT_TARGET}")
set(${OS_VERSION} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE)
endif()
Expand Down Expand Up @@ -611,6 +611,19 @@ macro(conan_provide_dependency_check)
endmacro()


macro(set_osx_deployment_target_flag)
if(NOT DEFINED $CACHE{CONAN_USE_CMAKE_OSX_DEPLOYMENT_TARGET})
if (DEFINED CMAKE_OSX_DEPLOYMENT_TARGET)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may want to do if DEFINED $CACHE{...} OR DEFINED $ENV{...} as both are valid ways for the user to express intent.

the non-cache CMAKE_OSX_DEPLOYMENT_TARGET can be defined too - we may want to ignore it, or raise a warning (since CMake documentation says that it may be overwritten completely during the call to project) - that could be an elseif()

set(CONAN_USE_CMAKE_OSX_DEPLOYMENT_TARGET TRUE CACHE BOOL
"Specifies whether CMAKE_OSX_DEPLOYMENT_TARGET should be use")
else()
set(CONAN_USE_CMAKE_OSX_DEPLOYMENT_TARGET FALSE CACHE BOOL
"Specifies whether CMAKE_OSX_DEPLOYMENT_TARGET should be use")
endif()
endif ()
endmacro()


# Add a deferred call at the end of processing the top-level directory
# to check if the dependency provider was invoked at all.
cmake_language(DEFER DIRECTORY "${CMAKE_SOURCE_DIR}" CALL conan_provide_dependency_check)
Expand All @@ -620,6 +633,8 @@ set(CONAN_HOST_PROFILE "default;auto-cmake" CACHE STRING "Conan host profile")
set(CONAN_BUILD_PROFILE "default" CACHE STRING "Conan build profile")
set(CONAN_INSTALL_ARGS "--build=missing" CACHE STRING "Command line arguments for conan install")

set_osx_deployment_target_flag()

find_program(_cmake_program NAMES cmake NO_PACKAGE_ROOT_PATH NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)
if(NOT _cmake_program)
get_filename_component(PATH_TO_CMAKE_BIN "${CMAKE_COMMAND}" DIRECTORY)
Expand Down