]> https://gitweb.dealii.org/ - dealii.git/commitdiff
CMake: Put RUN_COMMAND macro into separate file
authorMatthias Maier <tamiko@43-1.org>
Thu, 9 Mar 2017 23:44:37 +0000 (17:44 -0600)
committerMatthias Maier <tamiko@43-1.org>
Tue, 14 Mar 2017 16:12:49 +0000 (11:12 -0500)
Further, justify this approach with references to the official cmake
wiki.

cmake/macros/macro_configure_feature.cmake
cmake/macros/macro_evaluate_expression.cmake [new file with mode: 0644]

index 2e3f076a430a608d0dda2107b4db7aae3eaec78a..37ab173e6ebc710d876082aa6fe094d7831ffd66 100644 (file)
 #                                                                      #
 ########################################################################
 
-#
-# Some black magic to have substitution in command names:
-#
-MACRO(RUN_COMMAND _the_command)
-  FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/macro_configure_feature.tmp"
-    "${_the_command}")
-  INCLUDE("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/macro_configure_feature.tmp")
-ENDMACRO()
-
 
 #
 # A small macro to set the DEAL_II_WITH_${_feature} variables:
@@ -226,7 +217,7 @@ MACRO(CONFIGURE_FEATURE _feature)
         PURGE_FEATURE(${_feature})
 
         IF(FEATURE_${_feature}_HAVE_BUNDLED)
-          RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_BUNDLED()")
+          EVALUATE_EXPRESSION("FEATURE_${_feature}_CONFIGURE_BUNDLED()")
           MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with bundled packages.")
           SET(FEATURE_${_feature}_BUNDLED_CONFIGURED TRUE)
           SET_CACHED_OPTION(${_feature} ON)
@@ -242,14 +233,14 @@ MACRO(CONFIGURE_FEATURE _feature)
         # Second case: We are allowed to search for an external library
         #
         IF(COMMAND FEATURE_${_feature}_FIND_EXTERNAL)
-          RUN_COMMAND("FEATURE_${_feature}_FIND_EXTERNAL(FEATURE_${_feature}_EXTERNAL_FOUND)")
+          EVALUATE_EXPRESSION("FEATURE_${_feature}_FIND_EXTERNAL(FEATURE_${_feature}_EXTERNAL_FOUND)")
         ELSE()
           FEATURE_FIND_EXTERNAL(${_feature} FEATURE_${_feature}_EXTERNAL_FOUND)
         ENDIF()
 
         IF(FEATURE_${_feature}_EXTERNAL_FOUND)
           IF(COMMAND FEATURE_${_feature}_CONFIGURE_EXTERNAL)
-            RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_EXTERNAL()")
+            EVALUATE_EXPRESSION("FEATURE_${_feature}_CONFIGURE_EXTERNAL()")
           ENDIF()
 
           MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with external dependencies.")
@@ -263,7 +254,7 @@ MACRO(CONFIGURE_FEATURE _feature)
           MESSAGE(STATUS "DEAL_II_WITH_${_feature} has unmet external dependencies.")
 
           IF(FEATURE_${_feature}_HAVE_BUNDLED AND DEAL_II_ALLOW_BUNDLED)
-            RUN_COMMAND("FEATURE_${_feature}_CONFIGURE_BUNDLED()")
+            EVALUATE_EXPRESSION("FEATURE_${_feature}_CONFIGURE_BUNDLED()")
 
             MESSAGE(STATUS "DEAL_II_WITH_${_feature} successfully set up with bundled packages.")
             SET(FEATURE_${_feature}_BUNDLED_CONFIGURED TRUE)
@@ -272,7 +263,7 @@ MACRO(CONFIGURE_FEATURE _feature)
           ELSE()
             IF(DEAL_II_WITH_${_feature})
               IF(COMMAND FEATURE_${_feature}_ERROR_MESSAGE)
-                RUN_COMMAND("FEATURE_${_feature}_ERROR_MESSAGE()")
+                 EVALUATE_EXPRESSION("FEATURE_${_feature}_ERROR_MESSAGE()")
               ELSE()
                 FEATURE_ERROR_MESSAGE(${_feature})
               ENDIF()
diff --git a/cmake/macros/macro_evaluate_expression.cmake b/cmake/macros/macro_evaluate_expression.cmake
new file mode 100644 (file)
index 0000000..d467cb3
--- /dev/null
@@ -0,0 +1,31 @@
+## ---------------------------------------------------------------------
+##
+## Copyright (C) 2012 - 2017 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 at
+## the top level of the deal.II distribution.
+##
+## ---------------------------------------------------------------------
+
+#
+# A macro that evaluates an expression as supplied by a string. Suggestion
+# from the Wiki http://cmake.org/Wiki/CMake/Language_Syntax
+#
+# USAGE:
+#
+# EVALUATE_EXPRESSION("<expression>")
+#
+
+MACRO(EVALUATE_EXPRESSION _the_expression)
+  SET(_tmp_name
+    "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/evaluate_expression.tmp"
+    )
+  FILE(WRITE ${_tmp_name} "${_the_expression}")
+  INCLUDE("${_tmp_name}")
+ENDMACRO()

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.