diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2021-02-03 22:31:08 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-02-04 20:17:49 (GMT) |
commit | 657fc3a9a719831f9943c552e86e58ae283dad43 (patch) | |
tree | 244511bcf923be35fe38c22aea3a19580dbf93e6 /Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake | |
parent | c28dbd7e308968089bf97df71d4fd74c99e718f1 (diff) | |
download | CMake-657fc3a9a719831f9943c552e86e58ae283dad43.zip CMake-657fc3a9a719831f9943c552e86e58ae283dad43.tar.gz CMake-657fc3a9a719831f9943c552e86e58ae283dad43.tar.bz2 |
CMakeDetermineCompilerABI: Parse library arch from versioned paths
Teach CMake how to extract `CMAKE_<LANG>_LIBRARY_ARCHITECTURE` from
versioned paths such as `/usr/lib/gcc/x86_64-linux-gnu/9`. These kind of
paths are generated by NVHPC compilers.
Diffstat (limited to 'Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake')
-rw-r--r-- | Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake index bb6beb2..c46d044 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ParseImplicitLinkInfo.cmake @@ -50,6 +50,7 @@ else() endif() include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake) +include(${CMAKE_ROOT}/Modules/CMakeParseLibraryArchitecture.cmake) # # load_compiler_info: read infile, parsing out cmake compiler info @@ -80,6 +81,7 @@ function(load_compiler_info infile lang_var outcmvars_var outstr_var) message("load_compiler_info: ${infile} no LANG info; default to C") set(lang C) endif() + set(${lang_var} "${lang}" PARENT_SCOPE) set(${outcmvars_var} "${outcmvars}" PARENT_SCOPE) set(${outstr_var} "${outstr}" PARENT_SCOPE) @@ -94,6 +96,21 @@ function(unload_compiler_info cmvars) endforeach() endfunction() + +# +# load_platform_info: establish CMAKE_LIBRARY_ARCHITECTURE_REGEX +# based on the target platform. +# +function(load_platform_info target) + if(target MATCHES "linux-") + set(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*" PARENT_SCOPE) + set(CMAKE_LIBRARY_ARCHITECTURE_REGEX_VERSIONED "gcc/[a-z0-9_]+(-[a-z0-9_]+)?-linux(-gnu)?/[0-9]+(\\.[0-9]+\\.[0-9]+)*" PARENT_SCOPE) + else() + unset(CMAKE_LIBRARY_ARCHITECTURE_REGEX PARENT_SCOPE) + unset(CMAKE_LIBRARY_ARCHITECTURE_REGEX_VERSIONED PARENT_SCOPE) + endif() +endfunction() + # # main test loop # @@ -112,10 +129,12 @@ foreach(t ${targets}) endif() load_compiler_info(${infile} lang cmvars input) + load_platform_info(${t}) # Need to handle files with empty entries for both libs or dirs set(implicit_lib_output "") set(idirs_output "") + set(library_arch_output "") file(STRINGS ${outfile} outputs) foreach(line IN LISTS outputs) if(line MATCHES "libs=") @@ -124,13 +143,19 @@ foreach(t ${targets}) if(line MATCHES "dirs=") string(REPLACE "dirs=" "" idirs_output "${line}") endif() + if(line MATCHES "library_arch=") + string(REPLACE "library_arch=" "" library_arch_output "${line}") + endif() endforeach() cmake_parse_implicit_link_info("${input}" implicit_libs idirs implicit_fwks log "${CMAKE_${lang}_IMPLICIT_OBJECT_REGEX}") + set(library_arch) + cmake_parse_library_architecture("${idirs}" library_arch) + # File format - # file(WRITE ${outfile} "libs=${implicit_libs}\ndirs=${idirs}\n") + # file(WRITE ${outfile} "libs=${implicit_libs}\ndirs=${idirs}\nlibrary_arch=${library_arch}") if(t MATCHES "-empty$") # empty isn't supposed to parse if("${state}" STREQUAL "done") @@ -140,6 +165,8 @@ foreach(t ${targets}) message("${t} parse failed: state=${state}, '${idirs}' does not match '${idirs_output}'") elseif(NOT "${implicit_libs}" STREQUAL "${implicit_lib_output}") message("${t} parse failed: state=${state}, '${implicit_libs}' does not match '${implicit_lib_output}'") + elseif(library_arch AND NOT "${library_arch}" STREQUAL "${library_arch_output}") + message("${t} parse failed: state=${state}, '${library_arch}' does not match '${library_arch_output}'") endif() unload_compiler_info("${cmvars}") |