-
Notifications
You must be signed in to change notification settings - Fork 255
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
[feature] Design an internal macro to detect arch
setting, _conan_detect_arch()
.
#457
Comments
_conan_detect_arch()
to detect arch
setting.arch
setting, _conan_detect_arch()
.
This issue is related to: #448 |
In fact, CMake already defined a variable called CMAKE_LANG_COMPILER_ARCHITECTURE_ID, which should be able to detect the architecture of compilers currently used. However, this variable is NOT computed everywhere for now. Here are the links of related issues in CMake repository:
According to my experiments on Windows, the following compilers is computed:
Therefore, the implementation of macro(_conan_detect_arch)
conan_parse_arguments(${ARGV})
if (ARGUMENTS_ARCH)
set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH})
else ()
if ("${CMAKE_${LANGUAGE}_COMPILER_ID}" STREQUAL "MSVC"
OR ("${CMAKE_${LANGUAGE}_COMPILER_ID}" STREQUAL "Clang"
AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC"))
# using MSVC
# using MSVC-based Clang
if (CMAKE_${LANGUAGE}_COMPILER_ARCHITECTURE_ID MATCHES "64")
set(_CONAN_SETTING_ARCH x86_64)
elseif (CMAKE_${LANGUAGE}_COMPILER_ARCHITECTURE_ID MATCHES "^ARM")
set(_CONAN_SETTING_ARCH armv6)
elseif (CMAKE_${LANGUAGE}_COMPILER_ARCHITECTURE_ID MATCHES "86")
set(_CONAN_SETTING_ARCH x86)
else ()
# Other architectures...
endif()
else ()
# Other C/C++ compilers...
# Use other mechanism to detect its architecture
endif ()
endif ()
endmacro() Theoratically, once CMAKE_LANG_COMPILER_ARCHITECTURE_ID can be computed everywhere, the implementation should be able to reduce to: macro(_conan_detect_arch)
conan_parse_arguments(${ARGV})
if (ARGUMENTS_ARCH)
set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH})
else ()
if (CMAKE_${LANGUAGE}_COMPILER_ARCHITECTURE_ID MATCHES "64")
set(_CONAN_SETTING_ARCH x86_64)
elseif (CMAKE_${LANGUAGE}_COMPILER_ARCHITECTURE_ID MATCHES "^ARM")
set(_CONAN_SETTING_ARCH armv6)
elseif (CMAKE_${LANGUAGE}_COMPILER_ARCHITECTURE_ID MATCHES "86")
set(_CONAN_SETTING_ARCH x86)
else ()
# Other architectures...
endif()
endif ()
endmacro() |
Feature Request
In the
conan_cmake_autodetect()
macro (so far 1.18.1), there are some internal macros to detect the required settings:_conan_detect_build_type()
_conan_check_system_name()
_conan_check_language()
_conan_detect_compiler()
_collect_settings()
As we can see, there isn't a macro to detect
arch
setting. Only when we use MSVC compilers,_conan_detect_compiler()
will detect it specifically. Sincearch
is one of the required settings, I suggest that cmake-conan design an internal macro called_conan_detect_arch()
to do so.The text was updated successfully, but these errors were encountered: