Skip to content

Commit

Permalink
Add better mappings for windows subsystems and more CPU architectures
Browse files Browse the repository at this point in the history
  • Loading branch information
jcar87 committed Jun 26, 2023
1 parent 9baed3a commit 246dcd3
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
set(CONAN_MINIMUM_VERSION 2.0.5)


function(detect_os OS OS_API_LEVEL OS_VERSION)
function(detect_os OS OS_API_LEVEL OS_VERSION OS_SUBSYSTEM)
# 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")
Expand All @@ -11,6 +11,12 @@ function(detect_os OS OS_API_LEVEL OS_VERSION)
set(${OS_VERSION} ${CMAKE_OSX_DEPLOYMENT_TARGET} PARENT_SCOPE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "QNX")
set(${OS} Neutrino PARENT_SCOPE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} cygwin PARENT_SCOPE)
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "MSYS2")
set(${OS} Windows PARENT_SCOPE)
set(${OS_SUBSYSTEM} msys2 PARENT_SCOPE)
else()
set(${OS} ${CMAKE_SYSTEM_NAME} PARENT_SCOPE)
endif()
Expand All @@ -24,11 +30,11 @@ endfunction()


function(detect_arch ARCH)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64)
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|ARM64|arm64")
set(_ARCH armv8)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a|armv7l")
set(_ARCH armv7)
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL i686)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686")
set(_ARCH x86)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "AMD64|amd64|x86_64")
set(_ARCH x86_64)
Expand Down Expand Up @@ -103,7 +109,7 @@ endfunction()


function(detect_host_profile output_file)
detect_os(MYOS MYOS_API_LEVEL MYOS_VERSION)
detect_os(MYOS MYOS_API_LEVEL MYOS_VERSION MYOS_SUBSYSTEM)
detect_arch(MYARCH)
detect_compiler(MYCOMPILER MYCOMPILER_VERSION)
detect_cxx_standard(MYCXX_STANDARD)
Expand All @@ -125,6 +131,9 @@ function(detect_host_profile output_file)
if(MYOS_VERSION)
string(APPEND PROFILE os.version=${MYOS_VERSION} "\n")
endif()
if(MYOS_SUBSYSTEM)
string(APPEND PROFILE os.subsystem=${MYOS_SUBSYSTEM} "\n")
endif()
if(MYCOMPILER)
string(APPEND PROFILE compiler=${MYCOMPILER} "\n")
endif()
Expand Down

0 comments on commit 246dcd3

Please sign in to comment.