Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various tidy-ups (2) #581

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Changes from 4 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
27 changes: 17 additions & 10 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ function(detect_os OS OS_API_LEVEL OS_SDK OS_SUBSYSTEM OS_VERSION)
# it could be cross compilation
message(STATUS "CMake-Conan: cmake_system_name=${CMAKE_SYSTEM_NAME}")
if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic")
if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(${OS} Macos PARENT_SCOPE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "QNX")
elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(${OS} Neutrino PARENT_SCOPE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} cygwin PARENT_SCOPE)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "^MSYS")
elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} msys2 PARENT_SCOPE)
else()
set(${OS} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE)
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "Android")
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
string(REGEX MATCH "[0-9]+" _OS_API_LEVEL ${ANDROID_PLATFORM})
message(STATUS "CMake-Conan: android_platform=${ANDROID_PLATFORM}")
set(${OS_API_LEVEL} ${_OS_API_LEVEL} PARENT_SCOPE)
Expand Down Expand Up @@ -96,6 +96,7 @@ function(detect_cxx_standard CXX_STANDARD)
endif()
endfunction()


macro(detect_gnu_libstdcxx)
# _CONAN_IS_GNU_LIBSTDCXX true if GNU libstdc++
check_cxx_source_compiles("
Expand All @@ -118,6 +119,7 @@ macro(detect_gnu_libstdcxx)
unset (_CONAN_GNU_LIBSTDCXX_IS_CXX11_ABI)
endmacro()


macro(detect_libcxx)
# _CONAN_IS_LIBCXX true if LLVM libc++
check_cxx_source_compiles("
Expand All @@ -130,7 +132,7 @@ endmacro()


function(detect_lib_cxx OS LIB_CXX)
if(${OS} STREQUAL "Android")
if(OS STREQUAL "Android")
Copy link
Contributor

Choose a reason for hiding this comment

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

This one here is tricky - with the function being invoked like this:

detect_lib_cxx(MYOS MYLIB_CXX)

the value of OS inside this function is simply the string MYOS - so removing the reference (${OS}), causes this to compare the string MYOS which Android, which obviously fails.

This is the only of the detect_* functions that takes an input that is not the name of a variable to write to - so it makes it confusing.
I've refactored this to simply check in CMake for the current system name being Android, I think that's more in line with the rest of the file.

message(STATUS "CMake-Conan: android_stl=${ANDROID_STL}")
set(${LIB_CXX} ${ANDROID_STL} PARENT_SCOPE)
return()
Expand Down Expand Up @@ -198,7 +200,7 @@ function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUN
if(NOT CMAKE_MSVC_RUNTIME_LIBRARY IN_LIST _KNOWN_MSVC_RUNTIME_VALUES)
message(FATAL_ERROR "CMake-Conan: unable to map MSVC runtime: ${CMAKE_MSVC_RUNTIME_LIBRARY} to Conan settings")
endif()

# Runtime is "dynamic" in all cases if it ends in DLL
if(CMAKE_MSVC_RUNTIME_LIBRARY MATCHES ".*DLL$")
set(_COMPILER_RUNTIME "dynamic")
Expand Down Expand Up @@ -249,6 +251,7 @@ function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUN
set(${COMPILER_RUNTIME_TYPE} ${_COMPILER_RUNTIME_TYPE} PARENT_SCOPE)
endfunction()


function(detect_build_type BUILD_TYPE)
get_property(_MULTICONFIG_GENERATOR GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT _MULTICONFIG_GENERATOR)
Expand All @@ -258,6 +261,7 @@ function(detect_build_type BUILD_TYPE)
endif()
endfunction()


macro(append_compiler_executables_configuration)
set(_conan_c_compiler "")
set(_conan_cpp_compiler "")
Expand Down Expand Up @@ -342,7 +346,7 @@ function(detect_host_profile output_file)
# propagate compilers via profile
append_compiler_executables_configuration()

if(${MYOS} STREQUAL "Android")
if(MYOS STREQUAL "Android")
string(APPEND PROFILE "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n")
endif()

Expand Down Expand Up @@ -441,6 +445,7 @@ function(conan_version_check)
endif()
endfunction()


macro(construct_profile_argument argument_variable profile_list)
set(${argument_variable} "")
if("${profile_list}" STREQUAL "CONAN_HOST_PROFILE")
Expand Down Expand Up @@ -523,10 +528,11 @@ endmacro()


cmake_language(
SET_DEPENDENCY_PROVIDER conan_provide_dependency
SUPPORTED_METHODS FIND_PACKAGE
SET_DEPENDENCY_PROVIDER conan_provide_dependency
SUPPORTED_METHODS FIND_PACKAGE
)


macro(conan_provide_dependency_check)
set(_CONAN_PROVIDE_DEPENDENCY_INVOKED FALSE)
get_property(_CONAN_PROVIDE_DEPENDENCY_INVOKED GLOBAL PROPERTY CONAN_PROVIDE_DEPENDENCY_INVOKED)
Expand All @@ -543,6 +549,7 @@ macro(conan_provide_dependency_check)
unset(_CONAN_PROVIDE_DEPENDENCY_INVOKED)
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 Down
Loading