From 0b67da039bb54a17da2ef7803c8633bcef0b1b20 Mon Sep 17 00:00:00 2001 From: maier Date: Wed, 24 Oct 2012 15:50:36 +0000 Subject: [PATCH] Enhance autopilot macro git-svn-id: https://svn.dealii.org/branches/branch_cmake@27193 0785d39b-7218-0410-832d-ea1e28bc413d --- .../macro_deal_ii_invoke_autopilot.cmake | 88 +++++++++++-------- deal.II/config/Config.cmake.in | 2 +- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake index bc725e22b5..40a6cbac36 100644 --- a/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake +++ b/deal.II/cmake/macros/macro_deal_ii_invoke_autopilot.cmake @@ -24,52 +24,69 @@ # 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() diff --git a/deal.II/config/Config.cmake.in b/deal.II/config/Config.cmake.in index b53f84eab6..395fcecee4 100644 --- a/deal.II/config/Config.cmake.in +++ b/deal.II/config/Config.cmake.in @@ -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) -- 2.39.5