]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Enhance autopilot macro
authormaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Oct 2012 15:50:36 +0000 (15:50 +0000)
committermaier <maier@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 24 Oct 2012 15:50:36 +0000 (15:50 +0000)
git-svn-id: https://svn.dealii.org/branches/branch_cmake@27193 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake
deal.II/config/Config.cmake.in

index bc725e22b53cbed7b8a63098ecf4c60305a7c995..40a6cbac368343f00dd9c3524abdba241464e9c0 100644 (file)
 #       TARGET         -  a string used for the project and target name
 #       TARGET_SRC     -  a list of source file to compile for target
 #                         ${TARGET}
-#       CLEAN_UP_FILES - a list of files (globs) that will be removed with
-#                        runclean and distclean
+#       CLEAN_UP_FILES -  (optional) a list of files (globs) that will be
+#                         removed with "make runclean" and "make
+#                         distclean", will be set to default values if
+#                         empty
+#       RUN_COMMAND    -  (optional) the command line that should be
+#                         invoked by "make run", will be set to default
+#                         values if empty
 #
 
 MACRO(DEAL_II_INVOKE_AUTOPILOT)
 
-  MESSAGE(STATUS "Autopilot invoked")
-
   # Define and setup a compilation target:
   ADD_EXECUTABLE(${TARGET} ${TARGET_SRC})
   DEAL_II_SETUP_TARGET(${TARGET})
 
-  # Define a custom target to easily run the program:
-  ADD_CUSTOM_TARGET(run
-    COMMAND ${TARGET}
-    COMMENT "Run ${TARGET} compiled with ${CMAKE_BUILD_TYPE} configuration in ${CMAKE_SOURCE_DIR}"
-    )
+  IF(NOT "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
+
+    MESSAGE(STATUS "Out-of-source build. Target ${TARGET} defined but additional autopilot funcionality is not available.")
+
+  ELSE()
+
+    MESSAGE(STATUS "Autopilot invoked")
+
+    # Define a custom target to easily run the program:
+    IF("${RUN_COMMAND}" STREQUAL "")
+      SET(RUN_COMMAND ${TARGET})
+    ENDIF()
+    ADD_CUSTOM_TARGET(run
+      COMMAND ${RUN_COMMAND}
+      COMMENT "Run ${TARGET} compiled with ${CMAKE_BUILD_TYPE} configuration in ${CMAKE_SOURCE_DIR}"
+      )
 
-  # Define custom targets to easily switch the build type:
-  ADD_CUSTOM_TARGET(debug
-    COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
-    COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
-    )
-  ADD_CUSTOM_TARGET(release
-    COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
-    COMMENT "Switch CMAKE_BUILD_TYPE to Release"
-    )
+    # Define custom targets to easily switch the build type:
+    ADD_CUSTOM_TARGET(debug
+      COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Debug ${CMAKE_SOURCE_DIR}
+      COMMENT "Switch CMAKE_BUILD_TYPE to Debug"
+      )
+    ADD_CUSTOM_TARGET(release
+      COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=Release ${CMAKE_SOURCE_DIR}
+      COMMENT "Switch CMAKE_BUILD_TYPE to Release"
+      )
 
-  # And another custom target to clean up all files generated by the program:
-  ADD_CUSTOM_TARGET(runclean
-    COMMAND ${CMAKE_COMMAND} -E remove ${CLEAN_UP_FILES}
-    COMMENT "runclean invoked"
-    )
+    # And another custom target to clean up all files generated by the program:
+    IF("${CLEAN_UP_FILES}" STREQUAL "")
+      SET(CLEAN_UP_FILES *.log *.gmv *.gnuplot *.gpl *.eps *.pov *.vtk *.ucd *.d2)
+    ENDIF()
+    ADD_CUSTOM_TARGET(runclean
+      COMMAND ${CMAKE_COMMAND} -E remove ${CLEAN_UP_FILES}
+      COMMENT "runclean invoked"
+      )
 
-  # Define a distclean target to remove every generated file:
-  ADD_CUSTOM_TARGET(distclean
-    COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
-    COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target runclean
-    COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles
-    COMMAND ${CMAKE_COMMAND} -E remove
-      cmake_install.cmake CMakeCache.txt Makefile
-    COMMENT "distclean invoked"
-    )
+    # Define a distclean target to remove every generated file:
+    ADD_CUSTOM_TARGET(distclean
+      COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target clean
+      COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target runclean
+      COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles
+      COMMAND ${CMAKE_COMMAND} -E remove
+        cmake_install.cmake CMakeCache.txt Makefile
+      COMMENT "distclean invoked"
+      )
 
-  # Print out some usage information:
-  MESSAGE(
+    # Print out some usage information:
+    MESSAGE(
 "###
 #
 #  Successfully set up project  ${TARGET}  with  ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION}  found at
@@ -97,7 +114,8 @@ MACRO(DEAL_II_INVOKE_AUTOPILOT)
 #  Have a nice day!
 #
 ###"
-    )
+      )
+  ENDIF()
 
 ENDMACRO()
 
index b53f84eab6e5026b743d3dcf881f9658315fc0f3..395fcecee414078cccc1b2aebd40842669ab767a 100644 (file)
@@ -67,7 +67,7 @@ ENDIF()
 #
 
 FILE(GLOB _macro_files
-  "${DEAL_II_PATH}/${DEAL_II_CMAKE_MACROS_RELDIR}/*.cmake"
+  "${DEAL_II_PATH}/${DEAL_II_CMAKE_MACROS_RELDIR}/macro_deal_ii*.cmake"
   )
 FOREACH(file ${_macro_files})
   IF(NOT ${DEAL_II_PACKAGE_NAME}_FIND_QUIETLY)

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.