Skip to content

Commit

Permalink
Set detect_compiler 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 c989c6a commit da333a6
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions conan_provider.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,24 @@ function(detect_lib_cxx lib_cxx)
endfunction()


function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUNTIME_TYPE)
function(detect_compiler compiler compiler_version compiler_runtime compiler_runtime_type)
if(DEFINED CMAKE_CXX_COMPILER_ID)
set(_COMPILER ${CMAKE_CXX_COMPILER_ID})
set(_COMPILER_VERSION ${CMAKE_CXX_COMPILER_VERSION})
set(_compiler ${CMAKE_CXX_COMPILER_ID})
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
else()
if(NOT DEFINED CMAKE_C_COMPILER_ID)
message(FATAL_ERROR "C or C++ compiler not defined")
endif()
set(_COMPILER ${CMAKE_C_COMPILER_ID})
set(_COMPILER_VERSION ${CMAKE_C_COMPILER_VERSION})
set(_compiler ${CMAKE_C_COMPILER_ID})
set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
endif()

message(STATUS "CMake-Conan: CMake compiler=${_COMPILER}")
message(STATUS "CMake-Conan: CMake compiler version=${_COMPILER_VERSION}")
message(STATUS "CMake-Conan: CMake compiler=${_compiler}")
message(STATUS "CMake-Conan: CMake compiler version=${_compiler_version}")

if(_COMPILER MATCHES MSVC)
set(_COMPILER "msvc")
string(SUBSTRING ${MSVC_VERSION} 0 3 _COMPILER_VERSION)
if(_compiler MATCHES MSVC)
set(_compiler "msvc")
string(SUBSTRING ${MSVC_VERSION} 0 3 _compiler_version)
# Configure compiler.runtime and compiler.runtime_type settings for MSVC
if(CMAKE_MSVC_RUNTIME_LIBRARY)
set(_msvc_runtime_library ${CMAKE_MSVC_RUNTIME_LIBRARY})
Expand All @@ -247,52 +247,52 @@ function(detect_compiler COMPILER COMPILER_VERSION COMPILER_RUNTIME COMPILER_RUN

# Runtime is "dynamic" in all cases if it ends in DLL
if(_msvc_runtime_library MATCHES ".*DLL$")
set(_COMPILER_RUNTIME "dynamic")
set(_compiler_runtime "dynamic")
else()
set(_COMPILER_RUNTIME "static")
set(_compiler_runtime "static")
endif()
message(STATUS "CMake-Conan: CMake compiler.runtime=${_COMPILER_RUNTIME}")
message(STATUS "CMake-Conan: CMake compiler.runtime=${_compiler_runtime}")

# Only define compiler.runtime_type when explicitly requested
# If a generator expression is used, let Conan handle it conditional on build_type
if(NOT _msvc_runtime_library MATCHES "<CONFIG:Debug>:Debug>")
if(_msvc_runtime_library MATCHES "Debug")
set(_COMPILER_RUNTIME_TYPE "Debug")
set(_compiler_runtime_type "Debug")
else()
set(_COMPILER_RUNTIME_TYPE "Release")
set(_compiler_runtime_type "Release")
endif()
message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_COMPILER_RUNTIME_TYPE}")
message(STATUS "CMake-Conan: CMake compiler.runtime_type=${_compiler_runtime_type}")
endif()

unset(_KNOWN_MSVC_RUNTIME_VALUES)

elseif(_COMPILER MATCHES AppleClang)
set(_COMPILER "apple-clang")
elseif(_compiler MATCHES AppleClang)
set(_compiler "apple-clang")
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
elseif(_COMPILER MATCHES Clang)
set(_COMPILER "clang")
list(GET VERSION_LIST 0 _compiler_version)
elseif(_compiler MATCHES Clang)
set(_compiler "clang")
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
elseif(_COMPILER MATCHES GNU)
set(_COMPILER "gcc")
list(GET VERSION_LIST 0 _compiler_version)
elseif(_compiler MATCHES GNU)
set(_compiler "gcc")
string(REPLACE "." ";" VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET VERSION_LIST 0 _COMPILER_VERSION)
list(GET VERSION_LIST 0 _compiler_version)
endif()

message(STATUS "CMake-Conan: [settings] compiler=${_COMPILER}")
message(STATUS "CMake-Conan: [settings] compiler.version=${_COMPILER_VERSION}")
if (_COMPILER_RUNTIME)
message(STATUS "CMake-Conan: [settings] compiler.runtime=${_COMPILER_RUNTIME}")
message(STATUS "CMake-Conan: [settings] compiler=${_compiler}")
message(STATUS "CMake-Conan: [settings] compiler.version=${_compiler_version}")
if (_compiler_runtime)
message(STATUS "CMake-Conan: [settings] compiler.runtime=${_compiler_runtime}")
endif()
if (_COMPILER_RUNTIME_TYPE)
message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_COMPILER_RUNTIME_TYPE}")
if (_compiler_runtime_type)
message(STATUS "CMake-Conan: [settings] compiler.runtime_type=${_compiler_runtime_type}")
endif()

set(${COMPILER} ${_COMPILER} PARENT_SCOPE)
set(${COMPILER_VERSION} ${_COMPILER_VERSION} PARENT_SCOPE)
set(${COMPILER_RUNTIME} ${_COMPILER_RUNTIME} PARENT_SCOPE)
set(${COMPILER_RUNTIME_TYPE} ${_COMPILER_RUNTIME_TYPE} PARENT_SCOPE)
set(${compiler} ${_compiler} PARENT_SCOPE)
set(${compiler_version} ${_compiler_version} PARENT_SCOPE)
set(${compiler_runtime} ${_compiler_runtime} PARENT_SCOPE)
set(${compiler_runtime_type} ${_compiler_runtime_type} PARENT_SCOPE)
endfunction()


Expand Down

0 comments on commit da333a6

Please sign in to comment.