From a34abf82b76e5a0f34dde0072e4db67565f142e0 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 18 Jul 2024 11:08:51 -0700 Subject: [PATCH 1/3] Improved naming of variables in detect_host_profile --- conan_provider.cmake | 86 ++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/conan_provider.cmake b/conan_provider.cmake index 9931247c..a220f204 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -358,74 +358,74 @@ endmacro() function(detect_host_profile output_file) - detect_os(MYOS MYOS_API_LEVEL MYOS_SDK MYOS_SUBSYSTEM MYOS_VERSION) - detect_arch(MYARCH) - detect_compiler(MYCOMPILER MYCOMPILER_VERSION MYCOMPILER_RUNTIME MYCOMPILER_RUNTIME_TYPE) - detect_cxx_standard(MYCXX_STANDARD) - detect_lib_cxx(MYLIB_CXX) - detect_build_type(MYBUILD_TYPE) + detect_os(_os _api_level _sdk _subsystem _version) + detect_arch(_argch) + detect_compiler(_compiler _compiler_version _compiler_runtime _compiler_runtime_type) + detect_cxx_standard(_cxx_standard) + detect_lib_cxx(_lib_cxx) + detect_build_type(_build_type) - set(PROFILE "") - string(APPEND PROFILE "[settings]\n") - if(MYARCH) - string(APPEND PROFILE arch=${MYARCH} "\n") + set(_profile "") + string(APPEND _profile "[settings]\n") + if(_argch) + string(APPEND _profile arch=${_argch} "\n") endif() - if(MYOS) - string(APPEND PROFILE os=${MYOS} "\n") + if(_os) + string(APPEND _profile os=${_os} "\n") endif() - if(MYOS_API_LEVEL) - string(APPEND PROFILE os.api_level=${MYOS_API_LEVEL} "\n") + if(_api_level) + string(APPEND _profile os.api_level=${_api_level} "\n") endif() - if(MYOS_VERSION) - string(APPEND PROFILE os.version=${MYOS_VERSION} "\n") + if(_version) + string(APPEND _profile os.version=${_version} "\n") endif() - if(MYOS_SDK) - string(APPEND PROFILE os.sdk=${MYOS_SDK} "\n") + if(_sdk) + string(APPEND _profile os.sdk=${_sdk} "\n") endif() - if(MYOS_SUBSYSTEM) - string(APPEND PROFILE os.subsystem=${MYOS_SUBSYSTEM} "\n") + if(_subsystem) + string(APPEND _profile os.subsystem=${_subsystem} "\n") endif() - if(MYCOMPILER) - string(APPEND PROFILE compiler=${MYCOMPILER} "\n") + if(_compiler) + string(APPEND _profile compiler=${_compiler} "\n") endif() - if(MYCOMPILER_VERSION) - string(APPEND PROFILE compiler.version=${MYCOMPILER_VERSION} "\n") + if(_compiler_version) + string(APPEND _profile compiler.version=${_compiler_version} "\n") endif() - if(MYCOMPILER_RUNTIME) - string(APPEND PROFILE compiler.runtime=${MYCOMPILER_RUNTIME} "\n") + if(_compiler_runtime) + string(APPEND _profile compiler.runtime=${_compiler_runtime} "\n") endif() - if(MYCOMPILER_RUNTIME_TYPE) - string(APPEND PROFILE compiler.runtime_type=${MYCOMPILER_RUNTIME_TYPE} "\n") + if(_compiler_runtime_type) + string(APPEND _profile compiler.runtime_type=${_compiler_runtime_type} "\n") endif() - if(MYCXX_STANDARD) - string(APPEND PROFILE compiler.cppstd=${MYCXX_STANDARD} "\n") + if(_cxx_standard) + string(APPEND _profile compiler.cppstd=${_cxx_standard} "\n") endif() - if(MYLIB_CXX) - string(APPEND PROFILE compiler.libcxx=${MYLIB_CXX} "\n") + if(_lib_cxx) + string(APPEND _profile compiler.libcxx=${_lib_cxx} "\n") endif() - if(MYBUILD_TYPE) - string(APPEND PROFILE "build_type=${MYBUILD_TYPE}\n") + if(_build_type) + string(APPEND _profile "build_type=${_build_type}\n") endif() if(NOT DEFINED output_file) - set(_FN "${CMAKE_BINARY_DIR}/profile") + set(_file_name "${CMAKE_BINARY_DIR}/profile") else() - set(_FN ${output_file}) + set(_file_name ${output_file}) endif() - string(APPEND PROFILE "[conf]\n") - string(APPEND PROFILE "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n") + string(APPEND _profile "[conf]\n") + string(APPEND _profile "tools.cmake.cmaketoolchain:generator=${CMAKE_GENERATOR}\n") # propagate compilers via profile append_compiler_executables_configuration() - if(MYOS STREQUAL "Android") - string(APPEND PROFILE "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n") + if(_os STREQUAL "Android") + string(APPEND _profile "tools.android:ndk_path=${CMAKE_ANDROID_NDK}\n") endif() - message(STATUS "CMake-Conan: Creating profile ${_FN}") - file(WRITE ${_FN} ${PROFILE}) - message(STATUS "CMake-Conan: Profile: \n${PROFILE}") + message(STATUS "CMake-Conan: Creating profile ${_file_name}") + file(WRITE ${_file_name} ${_profile}) + message(STATUS "CMake-Conan: Profile: \n${_profile}") endfunction() From daf92741beea1b9b36d3b35f8ef1f5c09b9383da Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 18 Jul 2024 11:13:42 -0700 Subject: [PATCH 2/3] Make detect_cxx_standard argument lower case --- conan_provider.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/conan_provider.cmake b/conan_provider.cmake index a220f204..6257d03d 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -127,10 +127,10 @@ function(detect_arch ARCH) endfunction() -function(detect_cxx_standard CXX_STANDARD) - set(${CXX_STANDARD} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) +function(detect_cxx_standard cxx_standard) + set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) if(CMAKE_CXX_EXTENSIONS) - set(${CXX_STANDARD} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE) + set(${cxx_standard} "gnu${CMAKE_CXX_STANDARD}" PARENT_SCOPE) endif() endfunction() From 214e8eb3127a0fde3606c77989a1049d3ac8ed99 Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Thu, 18 Jul 2024 11:14:40 -0700 Subject: [PATCH 3/3] Set cstd in host profile The cstd setting was added to Conan in v2.4.0. Similar to cppstd, it is used to indicate the selected C language standard. --- conan_provider.cmake | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/conan_provider.cmake b/conan_provider.cmake index 6257d03d..1a949828 100644 --- a/conan_provider.cmake +++ b/conan_provider.cmake @@ -127,6 +127,14 @@ function(detect_arch ARCH) endfunction() +function(detect_c_standard c_standard) + set(${c_standard} ${CMAKE_C_STANDARD} PARENT_SCOPE) + if(CMAKE_C_EXTENSIONS) + set(${c_standard} "gnu${CMAKE_C_STANDARD}" PARENT_SCOPE) + endif() +endfunction() + + function(detect_cxx_standard cxx_standard) set(${cxx_standard} ${CMAKE_CXX_STANDARD} PARENT_SCOPE) if(CMAKE_CXX_EXTENSIONS) @@ -361,6 +369,7 @@ function(detect_host_profile output_file) detect_os(_os _api_level _sdk _subsystem _version) detect_arch(_argch) detect_compiler(_compiler _compiler_version _compiler_runtime _compiler_runtime_type) + detect_c_standard(_c_standard) detect_cxx_standard(_cxx_standard) detect_lib_cxx(_lib_cxx) detect_build_type(_build_type) @@ -397,6 +406,9 @@ function(detect_host_profile output_file) if(_compiler_runtime_type) string(APPEND _profile compiler.runtime_type=${_compiler_runtime_type} "\n") endif() + if(_c_standard) + string(APPEND _profile compiler.cstd=${_c_standard} "\n") + endif() if(_cxx_standard) string(APPEND _profile compiler.cppstd=${_cxx_standard} "\n") endif()