From: maier Date: Tue, 23 Oct 2012 15:20:26 +0000 (+0000) Subject: An example for an autopilot CMakeLists.txt file X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e31f8daa1340abe416bed29ba9087fdc8b3ada77;p=dealii-svn.git An example for an autopilot CMakeLists.txt file git-svn-id: https://svn.dealii.org/branches/branch_cmake@27182 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-1/CMakeLists.txt b/deal.II/examples/step-1/CMakeLists.txt index 919393549c..976c1653fb 100644 --- a/deal.II/examples/step-1/CMakeLists.txt +++ b/deal.II/examples/step-1/CMakeLists.txt @@ -1,23 +1,120 @@ +########################################################################## +# # +# An autopilot CMakeLists.txt example for a small project # +# using the deal.II library # +# # +########################################################################## + +# Set the name of the project and target: +# +SET(TARGET "step-1") + +# Declare all source files the target consists of: +# +SET(TARGET_SRC + ${TARGET}.cc + # You can specify additional files here! + ) + +# Build and run the program in debug or optimized mode: +# +SET(DEBUG_MODE TRUE) + +# Specify file names that will be deleted when calling 'make distclean': +# +SET(CLEAN_UP_FILES *.log *.gmv *.gnuplot *.gpl *.eps *.pov *.vtk *.ucd *.d2) + +# If the deal.II library cannot be found because it is not installed at a +# default location (or your project resides under an uncommon place), you +# may specify additional hints for search paths here. They take precedence +# over the hard coded installation paths. +# +# SET(DEAL_II_DIRS +# "$ENV{HOME}/deal.II" +# "$ENV{HOME}/workspace/deal.II" +# ) + + +########################################################################## +# # +# Usually, you will not need to modify anything beyond this point... # +# # +########################################################################## + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) +# Search for the deal.II library: FIND_PACKAGE(deal.II 8.0 REQUIRED HINTS - "../../" - "../../../../../" - $ENV{DEAL_DIR} - $ENV{DEAL_II_DIR} + ${DEAL_II_DIRS} + # Additional hints for possible library locations: + ../ ../../ ../../../ ../../../../../ + # Also look for hints from environment: + $ENV{DEAL_II_DIR} $ENV{DEAL_DIR} ) DEAL_II_INITIALIZE_CACHED_VARIABLES() -PROJECT(step-1) +# Hide some configuration options: +MARK_AS_ADVANCED(CMAKE_BUILD_TYPE deal.II_DIR) + +# Set build type: +IF(DEBUG_MODE) + SET(CMAKE_BUILD_TYPE "Debug" CACHE FORCE "") +ELSE() + SET(CMAKE_BUILD_TYPE "Release" CACHE FORCE "") +ENDIF() -ADD_EXECUTABLE(step-1 step-1.cc) -DEAL_II_SETUP_TARGET(step-1) +PROJECT(${TARGET}) +# 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 step-1 + COMMAND ${TARGET} + COMMENT "Run ${TARGET} compiled with ${CMAKE_BUILD_TYPE} configuration in ${CMAKE_SOURCE_DIR}" + ) + +# 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} ) + +# Define a distclean target to remove every generated file: ADD_CUSTOM_TARGET(distclean - COMMAND make clean - COMMAND rm -f *gmv *gnuplot *gpl *eps *pov *vtk *ucd *.d2 + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_SOURCE_DIR} --target clean + COMMAND ${CMAKE_COMMAND} --build ${CMAKE_SOURCE_DIR} --target runclean + COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles + COMMAND ${CMAKE_COMMAND} -E remove + cmake_install.cmake CMakeCache.txt Makefile ) + +# Print out some usage information: +MESSAGE(" +### +# +# Successfully set up project ${TARGET} with ${DEAL_II_PACKAGE_NAME}-${DEAL_II_PACKAGE_VERSION} found at +# ${DEAL_II_PATH} +# +# CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE} +# TARGET_SRC: ${TARGET_SRC} +# +# You can now run: +# $ make - to compile and link the program +# $ make run - to (compile, link and) run the program +# +# $ make clean - to remove the generated executable as well as +# all intermediate compilation files +# $ make runclean - to remove all output generated by the program +# $ make distclean - to run purge the directory from _all_ generated +# files (includes clean, runclean and the removal +# of the generated build system) +# +# To change the configuration, please edit the CMakeLists.txt file. +# +# Have a nice day! +# +###" +) +