3
0
mirror of https://github.com/triqs/dft_tools synced 2024-07-17 00:20:39 +02:00

[cmake] In extract_flags.cmake inspect INTERFACE_COMPILE_FEATURES and add -std=.. flags accordingly

This commit is contained in:
Nils Wentzell 2021-02-01 09:42:03 -05:00
parent efad2fe6ef
commit 73aa51608e

View File

@ -12,7 +12,7 @@
# #
# You may obtain a copy of the License at # You may obtain a copy of the License at
# https://www.gnu.org/licenses/gpl-3.0.txt # https://www.gnu.org/licenses/gpl-3.0.txt
# Author: Nils Wentzell
# Recursively fetch all targets that the interface of a target depends upon # Recursively fetch all targets that the interface of a target depends upon
macro(get_all_interface_targets name target) macro(get_all_interface_targets name target)
@ -59,6 +59,13 @@ macro(extract_flags)
set(${target}_CXXFLAGS "${${target}_CXXFLAGS} ${opt}") set(${target}_CXXFLAGS "${${target}_CXXFLAGS} ${opt}")
endforeach() endforeach()
get_property_recursive(cxx_features TARGET ${target} PROPERTY INTERFACE_COMPILE_FEATURES)
if(cxx_std_20 IN_LIST cxx_features)
set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -std=c++20")
elseif(cxx_std_17 IN_LIST cxx_features)
set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -std=c++17")
endif()
get_property_recursive(defs TARGET ${target} PROPERTY INTERFACE_COMPILE_DEFINITIONS) get_property_recursive(defs TARGET ${target} PROPERTY INTERFACE_COMPILE_DEFINITIONS)
foreach(def ${defs}) foreach(def ${defs})
set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -D${def}") set(${target}_CXXFLAGS "${${target}_CXXFLAGS} -D${def}")