mirror of
https://github.com/triqs/dft_tools
synced 2025-01-08 20:33:16 +01:00
[cmake] In extract_flags allow extraction of BUILD_INTERFACE flags
This commit is contained in:
parent
dbed8f20d5
commit
aea8d18739
@ -6,7 +6,7 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/conf.py.in ${CMAKE_CURRENT_BINARY_DIR
|
||||
# -----------------------------------------------------------------------------
|
||||
add_custom_target(${PROJECT_NAME}_docs_cpp2rst)
|
||||
include(${PROJECT_SOURCE_DIR}/share/cmake/extract_flags.cmake)
|
||||
extract_flags(app4triqs_c)
|
||||
extract_flags(app4triqs_c BUILD_INTERFACE)
|
||||
separate_arguments(app4triqs_c_CXXFLAGS)
|
||||
macro(generate_docs header_file)
|
||||
add_custom_command(
|
||||
|
@ -51,7 +51,13 @@ macro(get_property_recursive)
|
||||
endmacro()
|
||||
|
||||
# Recursively fetch all compiler flags attached to the interface of a target
|
||||
macro(extract_flags target)
|
||||
macro(extract_flags)
|
||||
|
||||
cmake_parse_arguments(ARG "BUILD_INTERFACE" "" "" ${ARGN})
|
||||
|
||||
set(target ${ARGV0})
|
||||
unset(${target}_CXXFLAGS)
|
||||
unset(${target}_LDFLAGS)
|
||||
|
||||
get_property_recursive(opts TARGET ${target} PROPERTY INTERFACE_COMPILE_OPTIONS)
|
||||
foreach(opt ${opts})
|
||||
@ -84,8 +90,13 @@ macro(extract_flags target)
|
||||
endforeach()
|
||||
|
||||
# We have to replace generator expressions explicitly
|
||||
string(REGEX REPLACE "\\$<INSTALL_INTERFACE:([^ ]*)>" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}")
|
||||
string(REGEX REPLACE "\\$<INSTALL_INTERFACE:([^ ]*)>" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
|
||||
if(ARG_BUILD_INTERFACE)
|
||||
string(REGEX REPLACE "\\$<BUILD_INTERFACE:([^ ]*)>" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}")
|
||||
string(REGEX REPLACE "\\$<BUILD_INTERFACE:([^ ]*)>" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
|
||||
else()
|
||||
string(REGEX REPLACE "\\$<INSTALL_INTERFACE:([^ ]*)>" "\\1" ${target}_LDFLAGS "${${target}_LDFLAGS}")
|
||||
string(REGEX REPLACE "\\$<INSTALL_INTERFACE:([^ ]*)>" "\\1" ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
|
||||
endif()
|
||||
string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_LDFLAGS "${${target}_LDFLAGS}")
|
||||
string(REGEX REPLACE " [^ ]*\\$<[^ ]*:[^>]*>" "" ${target}_CXXFLAGS "${${target}_CXXFLAGS}")
|
||||
endmacro()
|
||||
|
Loading…
Reference in New Issue
Block a user