mirror of
https://github.com/reactos/CMake.git
synced 2024-12-12 13:56:00 +00:00
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
This commit is contained in:
parent
67fe57478b
commit
a7a0bf861a
@ -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}")
|
||||
|
Loading…
Reference in New Issue
Block a user