diff options
author | Brad King <brad.king@kitware.com> | 2020-12-04 13:25:37 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-12-04 13:27:02 (GMT) |
commit | 7068189657858c0a840594c2905b75c5a147b513 (patch) | |
tree | defa9a47a3190779c966ca4f18265027739aa434 /Modules/CMakeDetermineCompilerId.cmake | |
parent | e15d404cfda6c3bd8dd84c0668fd6f9d4fd35315 (diff) | |
parent | f25ac39deeba879bb521f5c6f6ed3bc79ad5602c (diff) | |
download | CMake-7068189657858c0a840594c2905b75c5a147b513.zip CMake-7068189657858c0a840594c2905b75c5a147b513.tar.gz CMake-7068189657858c0a840594c2905b75c5a147b513.tar.bz2 |
Merge topic 'compiler-id-extra-text'
f25ac39dee CMakeDetermineCompilerId: Tolerate stray text around INFO strings
5cb66f17ca CMakeDetermineCompilerId: Add whitespace to clarify logic
1ee99104f7 CMakeDetermineCompilerId: Filter IAR-AVR format INFO strings earlier
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5570
Diffstat (limited to 'Modules/CMakeDetermineCompilerId.cmake')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 33ac07e..b296ba7 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -755,19 +755,28 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) break() endif() endforeach() - set(COMPILER_ID_TWICE) + # With the IAR Compiler, some strings are found twice, first time as incomplete # list like "?<Constant "INFO:compiler[IAR]">". Remove the incomplete copies. list(FILTER CMAKE_${lang}_COMPILER_ID_STRINGS EXCLUDE REGEX "\\?<Constant \\\"") + + # The IAR-AVR compiler uses a binary format that places a '6' + # character (0x34) before each character in the string. Strip + # out these characters without removing any legitimate characters. + if(CMAKE_${lang}_COMPILER_ID_STRINGS MATCHES "(.)I.N.F.O.:.") + string(REGEX REPLACE "${CMAKE_MATCH_1}([^;])" "\\1" + CMAKE_${lang}_COMPILER_ID_STRINGS "${CMAKE_${lang}_COMPILER_ID_STRINGS}") + endif() + + # Remove arbitrary text that may appear before or after each INFO string. + string(REGEX MATCHALL "INFO:[A-Za-z0-9_]+\\[([^]\"]*)\\]" + CMAKE_${lang}_COMPILER_ID_STRINGS "${CMAKE_${lang}_COMPILER_ID_STRINGS}") + # In C# binaries, some strings are found more than once. list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_ID_STRINGS) + + set(COMPILER_ID_TWICE) foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS}) - # The IAR-AVR compiler uses a binary format that places a '6' - # character (0x34) before each character in the string. Strip - # out these characters without removing any legitimate characters. - if("${info}" MATCHES "(.)I.N.F.O.:.") - string(REGEX REPLACE "${CMAKE_MATCH_1}(.)" "\\1" info "${info}") - endif() if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]") if(COMPILER_ID) set(COMPILER_ID_TWICE 1) |