From: maier
+ How to interface with deal.II in your own
+ project
+
+
+
+
+ Table of contents
+
+
+
+
+ This section presents some CMakeLists.txt
examples for
+ potential use in your projects. A detailed description of the
+ deal.II project configuration is given in the
+ deal.II CMake ReadME.
+
+ The easiest way to write a CMakeLists.txt
file is to use
+ an "autopilot" style macro which mimics the old user
+ Makefile
behaviour. Here is an example for the step-1
+ tutorial program: (raw version.)
+
+ + # + # 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! + ) + + # + # (Optional) + # Specify a list of files (file globs) that will be removed + # with the "make runclean" and "make distclean" targets. + # If empty, sensible default values will be used. + # + SET(CLEAN_UP_FILES + # a custom list of globs, e.g. *.log *.vtk + ) + + # + # (Optional) + # A custom command line that should be invoked by "make run". If empty, + # ${TARGET} will be invoked. + # + SET(TARGET_RUN + # a custom command line, e.g. mpirun -np 2 ${TARGET} + ) + + # + # It is good practise to specify a version requirement: + # + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) + + # + # Find and import the deal.II project configuration: + # + FIND_PACKAGE(deal.II 8.0 REQUIRED + HINTS + ${DEAL_II_DIRS} ../ ../../ ../../../ ../../../../../ $ENV{DEAL_II_DIR} + # + # If the deal.II library cannot be found (because it is not installed at a + # default location or your project resides at an uncommon place), you + # can specify additional hints for search paths here, e.g. + # "$ENV{HOME}/workspace/deal.II" + # + ) + + # + # And let deal.II do the rest: + # + DEAL_II_INITIALIZE_CACHED_VARIABLES() + PROJECT(${TARGET}) + DEAL_II_INVOKE_AUTOPILOT() ++ + This
CMakeLists.txt
is intended for use with a small
+ project and in-source build:
+ + + $ cd step-1 + $ cmake . + + [...] + + ### + # + # Successfully set up project step-1 with deal.II-8.0.pre found at + # /usr/local + # + # CMAKE_BUILD_TYPE: Debug + # TARGET_SRC: step-1.cc + # + # You can now run + # $ make - to compile and link the program + # $ make run - to (compile, link and) run the program + # + # $ make debug - to switch the build type to "Debug" + # $ make release - to switch the build type to "Release" + # $ make edit_cache - to change (cached) configuration variables + # and rerun the configure and generate phases of CMake + # + # $ 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 clean the directory from _all_ generated + # files (includes clean, runclean and the removal + # of the generated build system) + # + # Have a nice day! + # + ### ++ + + +
+ For large projects the simple CMakeLists.txt
presented
+ above tends to be too inflexible.
+ So, if you wish to have more control about targets the
+ DEAL_II_SETUP_TARGET
macro might be of interest for you.
+ Here is a full example for the step-1 tutorial program:
+
+ + # + # It is good practise to specify a version requirement: + # + CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) + + # + # Find and import the deal.II project configuration: + # + FIND_PACKAGE(deal.II 8.0 REQUIRED + HINTS + ${DEAL_II_DIRS} ../ ../../ ../../../ ../../../../../ $ENV{DEAL_II_DIR} + # + # If the deal.II library cannot be found (because it is not installed at a + # default location or your project resides at an uncommon place), you + # can specify additional hints for search paths here, e.g. + # "$ENV{HOME}/workspace/deal.II" + # + ) + + # + # Initialize cached variables: This will set the compiler and + # compiler flags to the values deal.II was configured with, as well as, + # CMAKE_BUILD_TYPE to "Debug". + # These values can be altered by editing the cache via + # $ make edit_cache + # + DEAL_II_INITIALIZE_CACHED_VARIABLES() + + # + # PROJECT has to be called after DEAL_II_INITIALIZE_CACHED_VARIABLES + # otherwise CMake will have already set the compiler and compiler + # flags. + # + PROJECT(step-1) + + # + # Specify a target: + # + ADD_EXECUTABLE(step-1 step-1.cc) + + # + # DEAL_II_SETUP_TARGET will set up all necessary include paths, + # preprocessor definitions and the link interface: + # + DEAL_II_SETUP_TARGET(step-1) + + # + # (Optional) + # If you wish to have a "run" target for make, specify one: + # + ADD_CUSTOM_TARGET(run + COMMAND step-1 + COMMENT "Run ${TARGET} with ${CMAKE_BUILD_TYPE} configuration" + ) ++ + Further details can be found in the deal.II CMake ReadME. + + + +
+ The CMake build system sets up the following compatibility files (if
+ DEAL_II_COMPONENT_COMPAT_FILES
is set, which is default):
+
+ + ${CMAKE_INSTALL_PREFIX} + ./common/Make.global_options + ./common/scripts/expand_instantiations + ./common/scripts/make_dependencies + ./common/scripts/report_features ++ + Therefore, it should be sufficient to set
D
in the old
+ user Makefiles to:
+ + + D=/path/install/dir ++ where
/path/install/dir
is the directory set up via
+ CMAKE_INSTALL_PREFIX
(the path
+ deal.II was installed to).
+
+
+
+
+ + svn copy http://www.dealii.org/svn/dealii/trunk/ http://www.dealii.org/svn/dealii/branches/new-branch-name
+ svn switch http://www.dealii.org/svn/dealii/branches/new-branch-nameThis command assumes you are in the top level directory, the one @@ -74,6 +76,7 @@
+ svn merge ^/trunkThis command will only run if you have no local changes in your working diff --git a/deal.II/doc/development/toc.html b/deal.II/doc/development/toc.html index eef63e99a1..5bcdf928c2 100644 --- a/deal.II/doc/development/toc.html +++ b/deal.II/doc/development/toc.html @@ -41,7 +41,7 @@ This page provides extensive information about usage and development of the deal.II CMake build system. -
Example CMakeLists.txt: TODO
diff --git a/deal.II/doc/readme.html b/deal.II/doc/readme.html index 3fec4fda7e..e381fb88be 100644 --- a/deal.II/doc/readme.html +++ b/deal.II/doc/readme.html @@ -79,7 +79,7 @@ target="_top">deal.II Wiki! Most other combinations of POSIX-style operating systems and C++ - standards compliant compilers should also work. If they don't, please + Standard compliant compilers should also work. If they don't, please report it as a bug.