3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-23 04:43:42 +01:00

[cmake] In extract_flags.cmake, protect extraction of -L/usr/lib and fix filtering -I/usr/include

This commit is contained in:
Nils Wentzell 2020-07-14 18:29:39 -04:00
parent e2f4e9988e
commit 5a9fc1118b

View File

@ -76,14 +76,10 @@ macro(extract_flags)
list(REMOVE_ITEM sys_inc_dirs ${inc_dirs}) list(REMOVE_ITEM sys_inc_dirs ${inc_dirs})
endif() endif()
foreach(dir ${inc_dirs}) foreach(dir ${inc_dirs})
if(NOT dir STREQUAL "/usr/include")
set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -I${dir}") set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -I${dir}")
endif()
endforeach() endforeach()
foreach(dir ${sys_inc_dirs}) foreach(dir ${sys_inc_dirs})
if(NOT dir STREQUAL "/usr/include")
set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -isystem${dir}") set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -isystem${dir}")
endif()
endforeach() endforeach()
get_property_recursive(libs TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES) get_property_recursive(libs TARGET ${target} PROPERTY INTERFACE_LINK_LIBRARIES)
@ -117,4 +113,10 @@ macro(extract_flags)
# Remove all remaining generator expressions # Remove all remaining generator expressions
string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_LDFLAGS "${${target}_LDFLAGS}") string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_LDFLAGS "${${target}_LDFLAGS}")
string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_CXXFLAGS "${${target}_CXXFLAGS}") string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
# Filter out system directories from LDFLAGS and CXXFLAGS
string(REGEX REPLACE " -L/usr/lib " " " ${target}_LDFLAGS "${${target}_LDFLAGS}")
string(REGEX REPLACE " -I/usr/include " " " ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
string(REGEX REPLACE " -isystem/usr/include " " " ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
endmacro() endmacro()