From: Matthias Maier Date: Thu, 9 Mar 2017 23:44:37 +0000 (-0600) Subject: CMake: Put RUN_COMMAND macro into separate file X-Git-Tag: v8.5.0-rc1~41^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=681896120380485b1793d4e3627f3bc623ab46d7;p=dealii.git CMake: Put RUN_COMMAND macro into separate file Further, justify this approach with references to the official cmake wiki. --- diff --git a/cmake/macros/macro_configure_feature.cmake b/cmake/macros/macro_configure_feature.cmake index 2e3f076a43..37ab173e6e 100644 --- a/cmake/macros/macro_configure_feature.cmake +++ b/cmake/macros/macro_configure_feature.cmake @@ -67,15 +67,6 @@ # # ######################################################################## -# -# 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 index 0000000000..d467cb3fbf --- /dev/null +++ b/cmake/macros/macro_evaluate_expression.cmake @@ -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("") +# + +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()