diff options
Diffstat (limited to 'Modules/CMakeDetermineCompilerABI.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerABI.cmake | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 7e5b3751ba..cf028f1812 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -8,6 +8,7 @@ include(${CMAKE_ROOT}/Modules/CMakeParseImplicitIncludeInfo.cmake) include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) +include(${CMAKE_ROOT}/Modules/CMakeParseLibraryArchitecture.cmake) include(CMakeTestCompilerCommon) function(CMAKE_DETERMINE_COMPILER_ABI lang src) @@ -75,12 +76,25 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) message(CHECK_PASS "done") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log "Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n") - file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[A-Za-z0-9_]+\\[[^]]*\\]") + 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*([^]]*)\\]") + if("${info}" MATCHES "INFO:sizeof_dptr\\[0*([^]]*)\\]" AND NOT ABI_SIZEOF_DPTR) set(ABI_SIZEOF_DPTR "${CMAKE_MATCH_1}") endif() - if("${info}" MATCHES "INFO:abi\\[([^]]*)\\]") + 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() endforeach() @@ -91,6 +105,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() @@ -158,27 +176,9 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) set(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) set(CMAKE_${lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${implicit_fwks}" PARENT_SCOPE) - # Detect library architecture directory name. - if(CMAKE_LIBRARY_ARCHITECTURE_REGEX) - foreach(dir ${implicit_dirs}) - if("${dir}" MATCHES "/lib/${CMAKE_LIBRARY_ARCHITECTURE_REGEX}$") - get_filename_component(arch "${dir}" NAME) - set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${arch}" PARENT_SCOPE) - break() - endif() - endforeach() - elseif(CMAKE_CXX_COMPILER_ID STREQUAL QCC) - foreach(dir ${implicit_dirs}) - if (dir MATCHES "/lib$") - get_filename_component(assumedArchDir "${dir}" DIRECTORY) - get_filename_component(archParentDir "${assumedArchDir}" DIRECTORY) - if (archParentDir STREQUAL CMAKE_SYSROOT) - get_filename_component(archDirName "${assumedArchDir}" NAME) - set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${archDirName}" PARENT_SCOPE) - break() - endif() - endif() - endforeach() + cmake_parse_library_architecture("${implicit_dirs}" architecture_flag) + if(architecture_flag) + set(CMAKE_${lang}_LIBRARY_ARCHITECTURE "${architecture_flag}" PARENT_SCOPE) endif() else() |