From: Matthias Maier Date: Wed, 23 Dec 2020 02:26:23 +0000 (-0600) Subject: CMake: Add a CLEAR_FEATURE macro and use it in PACKAGE_HANDLE X-Git-Tag: v9.3.0-rc1~719^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c3bd9a4202492452b5cae0753221f08a16db0ffd;p=dealii.git 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. --- 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$"