]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Prettify the macros
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 20 Sep 2012 00:11:17 +0000 (00:11 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Thu, 20 Sep 2012 00:11:17 +0000 (00:11 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@26540 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/contrib/cmake/check/check_for_compiler_features.cmake
deal.II/contrib/cmake/macros/macro_add_flags.cmake
deal.II/contrib/cmake/macros/macro_check_cxx_compiler_bug.cmake
deal.II/contrib/cmake/macros/macro_configure_feature.cmake
deal.II/contrib/cmake/macros/macro_enable_if_supported.cmake
deal.II/contrib/cmake/macros/macro_expand_instantiations.cmake
deal.II/contrib/cmake/macros/macro_get_cxx_source_return_value.cmake
deal.II/contrib/cmake/macros/macro_list_contains.cmake
deal.II/contrib/cmake/macros/macro_strip_flag.cmake

index 85f590a2b47a1066e55fb7224c32d1bde0d79bc7..c5f0ba59c1610ee304712b2ebbaa6277e4940378 100644 (file)
@@ -3,10 +3,12 @@
 #
 
 
+
 #
 # Check whether the std::vector::iterator is just a plain pointer
 #
-CHECK_CXX_COMPILER_BUG( # Yes. It is not a bug. But the logic is the same.
+# (Yes. It is not a bug. But the logic is the same.)
+CHECK_CXX_COMPILER_BUG(
   "
   #include <vector>
   template <typename T> void f(T) {}
@@ -398,3 +400,4 @@ IF(NOT CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
   ENABLE_IF_SUPPORTED(CMAKE_CXX_FLAGS_DEBUG "-Wa,--compress-debug-sections")
   ENABLE_IF_SUPPORTED(CMAKE_C_FLAGS_DEBUG "-Wa,--compress-debug-sections")
 ENDIF()
+
index 38acfad7ab998cf834f3372411316ee48e12e0b6..3e4728de9c6ad5e355ab6a03b4b60e41b4cbea2e 100644 (file)
@@ -1,3 +1,9 @@
+#
+# A small macro used for (string-)appending flags to a variable
+#
+# Usage:
+#     ADD_FLAGS(variable flag)
+#
 
 MACRO(ADD_FLAGS variable flag)
   SET(${variable} "${${variable}} ${flag}")
index 0e38b745983b368b73155f568a392b1880a05b6e..d69350adc8e87aef4426e312485c7678d004dde8 100644 (file)
@@ -1,12 +1,15 @@
-INCLUDE(CheckCXXSourceCompiles)
+#
+# Check for a compiler bug.
+#
+# Usage:
+#     CHECK_CXX_COMPILER_BUG(source var)
+#
+# where source is a snipped of source code and var is a variable that will
+# be set to true if source could not be compiled and linked successfully.
+# (This just inverts the logic of CHECK_CXX_SOURCE_COMPILES.)
+#
 
 MACRO(CHECK_CXX_COMPILER_BUG source var)
-
-  #
-  # Check for a compiler bug, i.e. if source does not compile, define var
-  # This just inverts the logic of CHECK_CXX_SOURCE_COMPILES.
-  #
-
   CHECK_CXX_SOURCE_COMPILES(
     "${source}"
     ${var}_OK)
@@ -17,5 +20,5 @@ MACRO(CHECK_CXX_COMPILER_BUG source var)
     MESSAGE(STATUS "Test unsuccessful, define ${var}")
     SET(${var} 1)
   ENDIF()
-
 ENDMACRO()
+
index 37e3e421a72682df013ac3342489120e6b6eaa00..18a319777d44a0b77cb4da6c7bc7c30a439cc990 100644 (file)
@@ -1,65 +1,65 @@
 #
-# This macro is used in the feature configuration mechanism of deal.II
+# This macro is used for the feature configuration in deal.II
 #
 # Usage:
+#     CONFIGURE_FEATURE(feature)
 #
-# CONFIGURE_FEATURE(feature)
 #
+# For a feature ${feature} (written in all caps) the following options,
+# variables and macros have to be defined (except marked as optional):
 #
-# This macro assumes the following macros and variables to be defined:
+# DEAL_II_WITH_${feature} (option, mandatory)
+#    determines whether the feature will be configured, if
+#    DEAL_II_FEATURE_AUTODETECTION is OFF. If
+#    DEAL_II_FEATURE_AUTODETECTION is ON, this option will be set if
+#    configuring the feature was successful.
 #
 # FEATURE_${feature}_DEPENDS (variable, optional)
-#
-#    a variable which contains an optional list of features this feature
-#    depends on (and which have to be enbled for this feature to work.)
-#
+#    a variable which contains an optional list of other features
+#    this feature depends on (and which have to be enbled for this feature
+#    to work.) The features must be given with the full option toggle:
+#    DEAL_II_WITH_[...]
 #
 # FEATURE_${feature}_HAVE_CONTRIB  (variable, optional)
-#
-#    which shall either be set to TRUE if all necessary libraries of the
+#    which should either be set to TRUE if all necessary libraries of the
 #    features comes bundled with deal.II and hence can be supported
 #    without external dependencies, or unset.
 #
 # FEATURE_${feature}_CONFIGURE_CONTRIB(var)  (macro, optional)
+#    which should setup all necessary configuration for the feature with
+#    contrib source dependencies. var set to TRUE indicates success,
+#    otherwise this script gives an error.
 #
-#    which shall setup all necessary configuration for the feature with
-#    contrib source dependencies. var set to TRUE shall indicate success.
-#
-#
-# FEATURE_${feature}_FIND_EXTERNAL(var)  (macro)
-#
-#    which shall set var to TRUE if all dependencies for the feature are
+# FEATURE_${feature}_FIND_EXTERNAL(var)  (macro, mandatory)
+#    which should set var to TRUE if all dependencies for the feature are
 #    fullfilled. In this case all necessary variables for
 #    FEATURE_${feature}_CONFIGURE_EXTERNAL must be set. Otherwise
 #    var should remain unset.
+#    This macro should give an error (SEND_ERROR or FATAL_ERROR).
 #
-# FEATURE_${feature}_CONFIGURE_EXTERNAL(var)  (macro)
-#
-#    which shall setup all necessary configuration for the feature with
-#    external dependencies. var set to TRUE shall indicate success.
+# FEATURE_${feature}_CONFIGURE_EXTERNAL(var)  (macro, mandatory)
 #
+#    which should setup all necessary configuration for the feature with
+#    external dependencies. var set to TRUE indicates success,
+#    otherwise this script gives an error.
 #
 # FEATURE_${feature}_CUSTOM_ERROR_MESSAGE() (variable, optional)
-#
-#    which shall either be set to TRUE if FEATURE_${feature}_ERROR_MESSAGE
+#    which should either be set to TRUE if FEATURE_${feature}_ERROR_MESSAGE
 #    is set up, or be undefined.
 #
 # FEATURE_${feature}_ERROR_MESSAGE()  (macro, optional)
-#
-#    which shall print a meaningfull error message if case no external
-#    library is found (and contrib is not allowed to be used.)
-#    If not defined, a suitable default error message will be printed.
+#    which should print a meaningfull error message (with SEND_ERROR) for
+#    the case that no external library was found (and contrib is not
+#    allowed to be used.) If not defined, a suitable default error message
+#    will be printed.
 #
 #
 
+
 #
-# FAT NOTE:
-# This script is arcane black magic. But at least for the better good: We
-# don't have to copy the configuration logic to every single
-# configure_<feature>.cmake script.
+# Some helper macros:
 #
 
-
 #
 # Some black magic to have substitution in command names:
 #
@@ -83,7 +83,7 @@ ENDMACRO()
 
 
 #
-# A small macro to post an error message:
+# A small macro to post a default error message:
 #
 MACRO(FEATURE_ERROR_MESSAGE feature)
   STRING(TOLOWER ${feature} feature_lowercase)
@@ -109,6 +109,12 @@ ENDMACRO()
 
 
 MACRO(CONFIGURE_FEATURE feature)
+  #
+  # This script is arcane black magic. But at least for the better good: We
+  # don't have to copy the configuration logic to every single
+  # configure_<feature>.cmake script...
+  #
+
 
   #
   # Check for correct include order of the configure_*.cmake files:
@@ -127,18 +133,17 @@ MACRO(CONFIGURE_FEATURE feature)
     ENDIF()
   ENDFOREACH()
 
-
+  #
   # Only try to configure ${feature} if we have to:
+  #
   IF(DEAL_II_FEATURE_AUTODETECTION OR DEAL_II_WITH_${feature})
 
     #
     # Are all dependencies fullfilled?
     #
     SET(macro_dependencies_ok TRUE)
-
     FOREACH(macro_dependency ${FEATURE_${feature}_DEPENDS})
       IF(NOT ${macro_dependency})
-
         IF(DEAL_II_FEATURE_AUTODETECTION)
           MESSAGE(STATUS
             "DEAL_II_WITH_${feature} has unmet configuration requirements: "
@@ -151,25 +156,19 @@ MACRO(CONFIGURE_FEATURE feature)
             "${macro_dependency} has to be set to \"ON\"."
             )
         ENDIF()
-
         SET(macro_dependencies_ok FALSE)
       ENDIF()
     ENDFOREACH()
 
-
     IF(macro_dependencies_ok)
-      #
-      # First case: DEAL_II_FORCE_CONTRIB_${feature} is defined:
-      #
       IF(DEAL_II_FORCE_CONTRIB_${feature})
+        #
+        # First case: DEAL_II_FORCE_CONTRIB_${feature} is defined:
+        #
 
         IF(FEATURE_${feature}_HAVE_CONTRIB)
           RUN_COMMAND(
-            "
-            FEATURE_${feature}_CONFIGURE_CONTRIB(
-              FEATURE_${feature}_CONTRIB_CONFIGURED
-              )
-            "
+            "FEATURE_${feature}_CONFIGURE_CONTRIB(FEATURE_${feature}_CONTRIB_CONFIGURED)"
             )
           IF(FEATURE_${feature}_CONTRIB_CONFIGURED)
             MESSAGE(STATUS
@@ -192,26 +191,20 @@ MACRO(CONFIGURE_FEATURE feature)
         ENDIF()
 
       ELSE(DEAL_II_FORCE_CONTRIB_${feature})
-
         #
-        # Second case: We are allowed to search for an external library:
+        # Second case: We are allowed to search for an external library
         #
+
         RUN_COMMAND(
           "FEATURE_${feature}_FIND_EXTERNAL(FEATURE_${feature}_EXTERNAL_FOUND)"
           )
 
         IF(FEATURE_${feature}_EXTERNAL_FOUND)
-
           MESSAGE(STATUS
             "All external dependencies for DEAL_II_WITH_${feature} are fullfilled."
             )
-
           RUN_COMMAND(
-            "
-            FEATURE_${feature}_CONFIGURE_EXTERNAL(
-              FEATURE_${feature}_EXTERNAL_CONFIGURED
-              )
-            "
+            "FEATURE_${feature}_CONFIGURE_EXTERNAL(FEATURE_${feature}_EXTERNAL_CONFIGURED)"
             )
 
           IF(FEATURE_${feature}_EXTERNAL_CONFIGURED)
@@ -228,7 +221,7 @@ MACRO(CONFIGURE_FEATURE feature)
               )
           ENDIF()
 
-        ELSE()
+        ELSE(FEATURE_${feature}_EXTERNAL_FOUND)
 
           MESSAGE(STATUS
             "DEAL_II_WITH_${feature} has unmet external dependencies."
@@ -236,11 +229,7 @@ MACRO(CONFIGURE_FEATURE feature)
 
           IF(FEATURE_${feature}_HAVE_CONTRIB AND DEAL_II_ALLOW_CONTRIB)
             RUN_COMMAND(
-              "
-              FEATURE_${feature}_CONFIGURE_CONTRIB(
-                FEATURE_${feature}_CONTRIB_CONFIGURED
-                )
-              "
+              "FEATURE_${feature}_CONFIGURE_CONTRIB(FEATURE_${feature}_CONTRIB_CONFIGURED)"
               )
             IF(FEATURE_${feature}_CONTRIB_CONFIGURED)
               MESSAGE(STATUS
@@ -260,22 +249,17 @@ MACRO(CONFIGURE_FEATURE feature)
                 SET_CACHED_OPTION(DEAL_II_WITH_${feature} OFF)
               ELSE()
                 IF(FEATURE_${feature}_CUSTOM_ERROR_MESSAGE)
-                  RUN_COMMAND(
-                    "
-                    FEATURE_${feature}_ERROR_MESSAGE()
-                    "
-                    )
+                  RUN_COMMAND("FEATURE_${feature}_ERROR_MESSAGE()")
                 ELSE()
                   FEATURE_ERROR_MESSAGE(${feature})
                 ENDIF()
               ENDIF()
           ENDIF()
-        ENDIF()
-      ENDIF(DEAL_II_FORCE_CONTRIB_${feature})
 
-    ENDIF()
-
-  ENDIF()
+        ENDIF(FEATURE_${feature}_EXTERNAL_FOUND)
+      ENDIF(DEAL_II_FORCE_CONTRIB_${feature})
+    ENDIF(macro_dependencies_ok)
+  ENDIF(DEAL_II_FEATURE_AUTODETECTION OR DEAL_II_WITH_${feature})
 
   SET(FEATURE_${feature}_PROCESSED TRUE)
 
index 04753df5fb43c417b77e91a8db822154bf0c6035..c936958d888ce470560fb16fe214bc9fb5aa1954 100644 (file)
@@ -1,8 +1,18 @@
+#
+# Tests whether the cxx compiler understands flag. If so, add it to
+# variable.
+#
+# Usage:
+#     ENABLE_IF_SUPPORTED(variable flag)
+#
+
 MACRO(ENABLE_IF_SUPPORTED variable flag)
   CHECK_CXX_COMPILER_FLAG(
     "${flag}"
-    DEAL_II_HAVE_FLAG_${flag})
+    DEAL_II_HAVE_FLAG_${flag}
+    )
   IF(DEAL_II_HAVE_FLAG_${flag})
     SET(${variable} "${${variable}} ${flag}")
   ENDIF()
 ENDMACRO()
+
index 8c37612fddfc28777361faa16bea49b5321d2070..7336bff86a639082f6ecccba08ed9b2e3033f741 100644 (file)
@@ -1,9 +1,8 @@
 #
-# A macro for the inst.in file expansion:
+# A macro for the inst.in file expansion
 #
 # Usage:
-#
-# macro_expand_instantiations(target inst_in_files)
+#     macro_expand_instantiations(target inst_in_files)
 #
 # Options:
 #
@@ -18,7 +17,6 @@
 #
 
 MACRO(macro_expand_instantiations target inst_in_files)
-
   FOREACH (inst_in_file ${inst_in_files})
     STRING(REGEX REPLACE "\\.in$" "" inst_file "${inst_in_file}" )
 
@@ -49,5 +47,5 @@ MACRO(macro_expand_instantiations target inst_in_files)
   # before target will be processed.
   #
   ADD_DEPENDENCIES(${target} ${target}.inst)
-
 ENDMACRO()
+
index 1ebc0301ed1842e56ad5caa0caa4962043c6996d..e79b3b0889835da1a448acef1194f785df91a4b1 100644 (file)
@@ -1,3 +1,6 @@
+#
+# TODO: Description...
+#
 MACRO(GET_CXX_SOURCE_RETURN_VALUE SOURCE VAR EXIT_CODE)
 
   #
index 6e38d25519d8f72d14b7fa3de56455af7e6e8712..e806c67883e3d5d34e2c8c1f878e4bbc10473812 100644 (file)
@@ -1,3 +1,13 @@
+#
+# A small macro to test whether a given list contains an element.
+#
+# Usage:
+#     LIST_CONTAINS(var value list)
+#
+# var is set to true if list contains value as an element compared via
+# STREQUAL.
+#
+
 MACRO(LIST_CONTAINS var value)
   SET(${var})
   FOREACH (value2 ${ARGN})
@@ -6,3 +16,4 @@ MACRO(LIST_CONTAINS var value)
     ENDIF (${value} STREQUAL ${value2})
   ENDFOREACH (value2)
 ENDMACRO(LIST_CONTAINS)
+
index fd663fc2cf6ee9e4afe72b03ad61f662837b0791..d5d046c5557c21a2aa5e20e7c65129b7630d36a2 100644 (file)
@@ -1,3 +1,9 @@
+#
+# Remove the first occurence of flag in the string variable.
+#
+# Usage:
+#     STRIP_FLAG(variable flag)
+#
 
 MACRO(STRIP_FLAG variable flag)
   IF(NOT "${variable}" STREQUAL "")

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.