# 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
# Have a nice day!
#
###"
- )
+ )
+ ENDIF()
ENDMACRO()