]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Add a CLEAR_FEATURE macro and use it in PACKAGE_HANDLE
authorMatthias Maier <tamiko@43-1.org>
Wed, 23 Dec 2020 02:26:23 +0000 (20:26 -0600)
committerMatthias Maier <tamiko@43-1.org>
Wed, 23 Dec 2020 02:28:10 +0000 (20:28 -0600)
Let's play it save and reset all "feature" variables (such as
<FEATURE>_INCLUDE_DIRS, <FEATURE>_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 <FEATURE>_CXX_FLAGS,
that we then accidentally use in our configuration even though this was
never intended.

cmake/macros/macro_clear_feature.cmake [new file with mode: 0644]
cmake/macros/macro_deal_ii_package_handle.cmake

diff --git a/cmake/macros/macro_clear_feature.cmake b/cmake/macros/macro_clear_feature.cmake
new file mode 100644 (file)
index 0000000..b71f6b0
--- /dev/null
@@ -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()
index 4c148eeab04e630f10de5944c8018804cfc4b52f..666c8961bf4eeb2e2e9ae7c23267fd34e08deb2d 100644 (file)
@@ -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$"

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.