Skip to content

Commit

Permalink
Set detect_os variables and arguments to lower-case snake-case
Browse files Browse the repository at this point in the history
  • Loading branch information
jhol committed Jul 31, 2024
1 parent da660a9 commit 31a7e01
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,58 +36,58 @@ cmake_policy(PUSH)
cmake_minimum_required(VERSION 3.24)


function(detect_os OS OS_API_LEVEL OS_SDK OS_SUBSYSTEM OS_VERSION)
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")
set(${OS} Macos PARENT_SCOPE)
set(${os} Macos PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "QNX")
set(${OS} Neutrino PARENT_SCOPE)
set(${os} Neutrino PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "CYGWIN")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} cygwin PARENT_SCOPE)
set(${os} Windows PARENT_SCOPE)
set(${os_subsystem} cygwin PARENT_SCOPE)
elseif(CMAKE_SYSTEM_NAME MATCHES "^MSYS")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} msys2 PARENT_SCOPE)
set(${os} Windows PARENT_SCOPE)
set(${os_subsystem} msys2 PARENT_SCOPE)
else()
set(${OS} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE)
set(${os} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Android")
if(DEFINED ANDROID_PLATFORM)
string(REGEX MATCH "[0-9]+" _OS_API_LEVEL ${ANDROID_PLATFORM})
string(REGEX MATCH "[0-9]+" os_api_level ${ANDROID_PLATFORM})
elseif(DEFINED CMAKE_SYSTEM_VERSION)
set(_OS_API_LEVEL ${CMAKE_SYSTEM_VERSION})
set(os_api_level ${CMAKE_SYSTEM_VERSION})
endif()
message(STATUS "CMake-Conan: android api level=${_OS_API_LEVEL}")
set(${OS_API_LEVEL} ${_OS_API_LEVEL} PARENT_SCOPE)
message(STATUS "CMake-Conan: android api level=${os_api_level}")
set(${os_api_level} ${os_api_level} PARENT_SCOPE)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS")
# CMAKE_OSX_SYSROOT contains the full path to the SDK for MakeFile/Ninja
# generators, but just has the original input string for Xcode.
if(NOT IS_DIRECTORY ${CMAKE_OSX_SYSROOT})
set(_OS_SDK ${CMAKE_OSX_SYSROOT})
set(_os_sdk ${CMAKE_OSX_SYSROOT})
else()
if(CMAKE_OSX_SYSROOT MATCHES Simulator)
set(apple_platform_suffix simulator)
else()
set(apple_platform_suffix os)
endif()
if(CMAKE_OSX_SYSROOT MATCHES AppleTV)
set(_OS_SDK "appletv${apple_platform_suffix}")
set(_os_sdk "appletv${apple_platform_suffix}")
elseif(CMAKE_OSX_SYSROOT MATCHES iPhone)
set(_OS_SDK "iphone${apple_platform_suffix}")
set(_os_sdk "iphone${apple_platform_suffix}")
elseif(CMAKE_OSX_SYSROOT MATCHES Watch)
set(_OS_SDK "watch${apple_platform_suffix}")
set(_os_sdk "watch${apple_platform_suffix}")
endif()
endif()
if(DEFINED _OS_SDK)
if(DEFINED os_sdk)
message(STATUS "CMake-Conan: cmake_osx_sysroot=${CMAKE_OSX_SYSROOT}")
set(${OS_SDK} ${_OS_SDK} PARENT_SCOPE)
set(${os_sdk} ${_os_sdk} PARENT_SCOPE)
endif()
if(DEFINED 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)
set(${os_version} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE)
endif()
endif()
endif()
Expand Down

0 comments on commit 31a7e01

Please sign in to comment.