diff options
author | Brad King <brad.king@kitware.com> | 2020-11-03 21:57:16 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-11-04 15:08:13 (GMT) |
commit | f511a1c00912f3e1d368a423b07bd1a1ab57fab3 (patch) | |
tree | e4feec49632b94694eb09fbfaef8cc57debf0aec /Modules/CMakeDetermineCompilerABI.cmake | |
parent | 606b34b3a6eeac1bcd64c274b5407cc2cd6be2bd (diff) | |
download | CMake-f511a1c00912f3e1d368a423b07bd1a1ab57fab3.zip CMake-f511a1c00912f3e1d368a423b07bd1a1ab57fab3.tar.gz CMake-f511a1c00912f3e1d368a423b07bd1a1ab57fab3.tar.bz2 |
CMakeDetermineCompilerABI: Detect byte order as part of check
We already detect `sizeof(void*)`. Detect the byte order as part of the
same check.
Issue: #21392
Diffstat (limited to 'Modules/CMakeDetermineCompilerABI.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 3fa99df..67c42a2a 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -77,11 +77,22 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 32 REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]") set(ABI_SIZEOF_DPTR "NOTFOUND") + set(ABI_BYTE_ORDER "NOTFOUND") set(ABI_NAME "NOTFOUND") foreach(info ${ABI_STRINGS}) if("${info}" MATCHES "INFO:sizeof_dptr\\[0*([^]]*)\\]" AND NOT ABI_SIZEOF_DPTR) set(ABI_SIZEOF_DPTR "${CMAKE_MATCH_1}") endif() + if("${info}" MATCHES "INFO:byte_order\\[(BIG_ENDIAN|LITTLE_ENDIAN)\\]") + set(byte_order "${CMAKE_MATCH_1}") + if(ABI_BYTE_ORDER STREQUAL "NOTFOUND") + # Tentatively use the value because this is the first occurrence. + set(ABI_BYTE_ORDER "${byte_order}") + elseif(NOT ABI_BYTE_ORDER STREQUAL "${byte_order}") + # Drop value because multiple occurrences do not match. + set(ABI_BYTE_ORDER "") + endif() + endif() if("${info}" MATCHES "INFO:abi\\[([^]]*)\\]" AND NOT ABI_NAME) set(ABI_NAME "${CMAKE_MATCH_1}") endif() @@ -93,6 +104,10 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) set(CMAKE_${lang}_SIZEOF_DATA_PTR "${CMAKE_${lang}_SIZEOF_DATA_PTR_DEFAULT}" PARENT_SCOPE) endif() + if(ABI_BYTE_ORDER) + set(CMAKE_${lang}_BYTE_ORDER "${ABI_BYTE_ORDER}" PARENT_SCOPE) + endif() + if(ABI_NAME) set(CMAKE_${lang}_COMPILER_ABI "${ABI_NAME}" PARENT_SCOPE) endif() |