From c3bd9a4202492452b5cae0753221f08a16db0ffd Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 22 Dec 2020 20:26:23 -0600 Subject: [PATCH] CMake: Add a CLEAR_FEATURE macro and use it in PACKAGE_HANDLE Let's play it save and reset all "feature" variables (such as _INCLUDE_DIRS, _LIBRARIES, etc.) before we populate them in DEAL_II_PACKAGE_HANDLE(...). This guards against issues where we include an external project configuration that actually sets variables, such as _CXX_FLAGS, that we then accidentally use in our configuration even though this was never intended. --- cmake/macros/macro_clear_feature.cmake | 34 +++++++++++++++++++ .../macros/macro_deal_ii_package_handle.cmake | 2 ++ 2 files changed, 36 insertions(+) create mode 100644 cmake/macros/macro_clear_feature.cmake diff --git a/cmake/macros/macro_clear_feature.cmake b/cmake/macros/macro_clear_feature.cmake new file mode 100644 index 0000000000..b71f6b00ea --- /dev/null +++ b/cmake/macros/macro_clear_feature.cmake @@ -0,0 +1,34 @@ +## --------------------------------------------------------------------- +## +## Copyright (C) 2020 by the deal.II authors +## +## This file is part of the deal.II library. +## +## The deal.II library is free software; you can use it, redistribute +## it, and/or modify it under the terms of the GNU Lesser General +## Public License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## The full text of the license can be found in the file LICENSE.md at +## the top level directory of deal.II. +## +## --------------------------------------------------------------------- + +# +# This macro is used for the feature configuration in deal.II. It clears +# all individual FEATURE_* configuration variables for a given feature. +# +# Usage: +# CLEAR_FEATURE(feature) +# +# and all other suffixes defined in DEAL_II_LIST_SUFFIXES and +# DEAL_II_STRING_SUFFIXES to the corresponding DEAL_II_* variables +# + +MACRO(CLEAR_FEATURE _feature) + FOREACH(_var ${DEAL_II_LIST_SUFFIXES}) + unset(${_feature}_${_var}) + ENDFOREACH() + FOREACH(_var ${DEAL_II_STRING_SUFFIXES}) + unset(${_feature}_${_var}) + ENDFOREACH() +ENDMACRO() diff --git a/cmake/macros/macro_deal_ii_package_handle.cmake b/cmake/macros/macro_deal_ii_package_handle.cmake index 4c148eeab0..666c8961bf 100644 --- a/cmake/macros/macro_deal_ii_package_handle.cmake +++ b/cmake/macros/macro_deal_ii_package_handle.cmake @@ -67,6 +67,8 @@ MACRO(DEAL_II_PACKAGE_HANDLE _feature _var) SET(_fill_clear FALSE) SET(_clear "") + CLEAR_FEATURE(${_feature}) + FOREACH(_arg ${ARGN}) IF(_arg MATCHES "^LIBRARIES(|_DEBUG|_RELEASE)$" OR _arg MATCHES "^(|BUNDLED_|USER_)INCLUDE_DIRS$" -- 2.39.5