diff options
author | Thierry Crozat <criezy@scummvm.org> | 2017-06-16 18:50:27 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-06-19 17:56:09 (GMT) |
commit | a7a0bf861ad434063228146790e6403f5743d2b9 (patch) | |
tree | ad427680664021a8398ffa18dc98e39c1ad3daa8 /Modules/FindwxWidgets.cmake | |
parent | 67fe57478b88fac76595d71e74934970ca6960f4 (diff) | |
download | CMake-a7a0bf861ad434063228146790e6403f5743d2b9.zip CMake-a7a0bf861ad434063228146790e6403f5743d2b9.tar.gz CMake-a7a0bf861ad434063228146790e6403f5743d2b9.tar.bz2 |
FindwxWidgets: Fix parsing of cxxflags when paths contain -D or -I
Use proper command-line parsing rather than accidentally matching
content in the middle of paths that looks like flags.
Fixes: #16986
Diffstat (limited to 'Modules/FindwxWidgets.cmake')
-rw-r--r-- | Modules/FindwxWidgets.cmake | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake index af4daf0..63f2c60 100644 --- a/Modules/FindwxWidgets.cmake +++ b/Modules/FindwxWidgets.cmake @@ -778,28 +778,24 @@ else() ) if(RET EQUAL 0) string(STRIP "${wxWidgets_CXX_FLAGS}" wxWidgets_CXX_FLAGS) - separate_arguments(wxWidgets_CXX_FLAGS) + separate_arguments(wxWidgets_CXX_FLAGS_LIST NATIVE_COMMAND "${wxWidgets_CXX_FLAGS}") DBG_MSG_V("wxWidgets_CXX_FLAGS=${wxWidgets_CXX_FLAGS}") - # parse definitions from cxxflags; - # drop -D* from CXXFLAGS and the -D prefix - string(REGEX MATCHALL "-D[^;]+" - wxWidgets_DEFINITIONS "${wxWidgets_CXX_FLAGS}") - string(REGEX REPLACE "-D[^;]+(;|$)" "" - wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") - string(REGEX REPLACE ";$" "" - wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") - string(REPLACE "-D" "" - wxWidgets_DEFINITIONS "${wxWidgets_DEFINITIONS}") - - # parse include dirs from cxxflags; drop -I prefix - string(REGEX MATCHALL "-I[^;]+" - wxWidgets_INCLUDE_DIRS "${wxWidgets_CXX_FLAGS}") - string(REGEX REPLACE "-I[^;]+;" "" - wxWidgets_CXX_FLAGS "${wxWidgets_CXX_FLAGS}") - string(REPLACE "-I" "" - wxWidgets_INCLUDE_DIRS "${wxWidgets_INCLUDE_DIRS}") + # parse definitions and include dirs from cxxflags + # drop the -D and -I prefixes + set(wxWidgets_CXX_FLAGS) + foreach(arg IN LISTS wxWidgets_CXX_FLAGS_LIST) + if("${arg}" MATCHES "^-I(.*)$") + # include directory + list(APPEND wxWidgets_INCLUDE_DIRS "${CMAKE_MATCH_1}") + elseif("${arg}" MATCHES "^-D(.*)$") + # compile definition + list(APPEND wxWidgets_DEFINITIONS "${CMAKE_MATCH_1}") + else() + list(APPEND wxWidgets_CXX_FLAGS "${arg}") + endif() + endforeach() DBG_MSG_V("wxWidgets_DEFINITIONS=${wxWidgets_DEFINITIONS}") DBG_MSG_V("wxWidgets_INCLUDE_DIRS=${wxWidgets_INCLUDE_DIRS}") |