From 287f299314ee96fd2047ff6d888289225c686dbb Mon Sep 17 00:00:00 2001 From: Eugene Shalygin Date: Sat, 26 May 2018 01:57:32 +0200 Subject: [PATCH] cmake: pass target C++ standard to pkgconfig generator --- cmake/Modules/GeneratePkgConfig.cmake | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/GeneratePkgConfig.cmake b/cmake/Modules/GeneratePkgConfig.cmake index 55df54477..e668bc377 100644 --- a/cmake/Modules/GeneratePkgConfig.cmake +++ b/cmake/Modules/GeneratePkgConfig.cmake @@ -9,6 +9,24 @@ set(_GeneratePkGConfigDir "${CMAKE_CURRENT_LIST_DIR}/GeneratePkgConfig") include(GNUInstallDirs) +function(_compile_features_to_gcc_flags _res _features) + set(features ${_features}) + # leave only cxx_std_nn items + list(FILTER features INCLUDE REGEX cxx_std_) + if (${features} STREQUAL "") + set(${_res} "" PARENT_SCOPE) + else() + # if there are more than a single cxx_std_nn feature... + list(SORT features) + # take the most recent standard, i.e. the last element + list(GET features -1 standard) + # cmake calls it cxx_std_98, but we (obviously) want -std=c++03 + string(REPLACE 98 03 standard "${standard}") + string(REPLACE cxx_std_ -std=c++ standard "${standard}") + set(${_res} "${standard}" PARENT_SCOPE) + endif() +endfunction() + function(_get_target_property_merging_configs _var_name _target_name _propert_name) get_target_property(vals ${_target_name} ${_propert_name}) if (NOT vals) @@ -31,8 +49,9 @@ function(_get_target_property_merging_configs _var_name _target_name _propert_na endif() endforeach() endif() - # HACK file(GENERATE), which we use foe expanding generator expressions, is BUILD_INTERFACE, + # HACK file(GENERATE), which we use for expanding generator expressions, is BUILD_INTERFACE, # but we need INSTALL_INTERFACE here. As such, let us inter-change them. + # See https://gitlab.kitware.com/cmake/cmake/issues/17984 string(REPLACE "$