From 5c8f06e4c89ff6ee58ef11035de7feb7b628153b Mon Sep 17 00:00:00 2001 From: "Wang, Xiang W" Date: Mon, 25 Mar 2019 06:02:39 -0400 Subject: [PATCH] gcc-9: fix CMake parsing of CPU architecture GCC-9 adds known options section for march that causes regex replace failure in CMake file Fixes github issue #136 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cac4fab7..5601c287 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -191,6 +191,8 @@ else() set (EXEC_ARGS ${CC_ARG1} -c -Q --help=target -march=native -mtune=native) execute_process(COMMAND ${CMAKE_C_COMPILER} ${EXEC_ARGS} OUTPUT_VARIABLE _GCC_OUTPUT) + string(FIND "${_GCC_OUTPUT}" "Known" POS) + string(SUBSTRING "${_GCC_OUTPUT}" 0 ${POS} _GCC_OUTPUT) string(REGEX REPLACE ".*march=[ \t]*([^ \n]*)[ \n].*" "\\1" GNUCC_ARCH "${_GCC_OUTPUT}")