From 828714b91b388effbbc0a16fb328dc2a5699f9bc Mon Sep 17 00:00:00 2001
From: kanschat
+
How to interface with deal.II in your own
project
-
-
- Table of contents
cmake
is the configuration and build tool we use
@@ -56,38 +57,105 @@
deal.II CMake ReadMe.)
+ For larger 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
+ (plain text version):
+
+ TODO: Fix plain text after finalizing!
+
+ TODO: Do some nicer formatting of pre. Here and possibly
+ globally. Do not use indentation by hand for this.
+
+
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) + +FIND_PACKAGE(deal.II 8.0 REQUIRED + HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} +) + +DEAL_II_INITIALIZE_CACHED_VARIABLES() +PROJECT(myproject CXX) + +ADD_EXECUTABLE(mycode mycode.cc) +DEAL_II_SETUP_TARGET(mycode) ++ + TODO: Explain the two macros! + + +
In order to specify multiple executable targets, simply repeat the last two lines of the simple CMakeLists.txt
:
+ADD_EXECUTABLE(mycode2 mycode2.cc) +DEAL_II_SETUP_TARGET(mycode2) + +ADD_EXECUTABLE(mycode3 mycode3.cc) +DEAL_II_SETUP_TARGET(mycode3) ++ +If the list gets longer, consider using +a loop, possibly +with GLOB. + + +
+ If you wish to have a "run" target for make, like in the deal.II + tutorial, specify one this way (obviously, a single "run" target + can only run a single executable): +
+ ++ADD_CUSTOM_TARGET(run COMMAND mycode + COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration") ++ +
- The easiest way to write a CMakeLists.txt
file is to use
+ If you want a make interface similar to the deal.II library and
+ its tutorial, namely maker targets for debug and release
+ versions, running the code and cleaning, the easiest way to
+ write a CMakeLists.txt
file may be to use
an "autopilot" style macro. Here is a minimalistic example for the
step-1 tutorial program (plain text version) that can be used for simple
projects:
-
+ - FIND_PACKAGE(deal.II 8.0 REQUIRED - HINTS - ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - # You can specify additional hints for search paths here, e.g. - # $ENV{HOME}/workspace/deal.II - ) - - # Set the name of the project and target: - SET(TARGET "step-1") - - # Declare all source files the target consists of: - SET(TARGET_SRC - step-1.cc - # You can specify additional files here! - ) - - CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - DEAL_II_INITIALIZE_CACHED_VARIABLES() - PROJECT(${TARGET} CXX) - DEAL_II_INVOKE_AUTOPILOT() -+
+FIND_PACKAGE(deal.II 8.0 REQUIRED + HINTS + ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} + # You can specify additional hints for search paths here, e.g. + # $ENV{HOME}/workspace/deal.II +) + +# Set the name of the project and target: +SET(TARGET "step-1") + +# Declare all source files the target consists of: +SET(TARGET_SRC + step-1.cc + # You can specify additional files here! +) + +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) +DEAL_II_INITIALIZE_CACHED_VARIABLES() +PROJECT(${TARGET} CXX) +DEAL_II_INVOKE_AUTOPILOT() +This
CMakeLists.txt
is intended for use with a small
@@ -96,109 +164,67 @@
in the readme
file). Using this input file, you can run cmake
in the
source directory as follows:
- - $ cd step-1 - $ cmake . - - [...] - - ### - # - # Successfully set up project step-1 with deal.II-99.99.svn30300 found at - # /usr - # - # CMAKE_BUILD_TYPE: Debug - # - # 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 strip_comments - strip the source files in this - # directory off the documentation comments - # $ 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) - # - # $ make help - to view this message again - # - # Have a nice day! - # - ### -+
+$ cd step-1 +$ cmake . + +[...] + +### +# +# Successfully set up project step-1 with deal.II-99.99.svn30300 found at +# /usr +# +# CMAKE_BUILD_TYPE: Debug +# +# 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 strip_comments - strip the source files in this +# directory off the documentation comments +# $ 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) +# +# $ make help - to view this message again +# +# Have a nice day! +# +### ++ There are two additional configuration options (in addition to
TARGET
and TARGET_SRC
) that can be set via
variables before DEAL_II_INVOKE_AUTOPILOT()
is called
(plain text version):
- - - # (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} - ) -- - - - - -
- For larger 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, again using the
- step-1 tutorial program as a template (plain text version):
-
- - CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8) - - FIND_PACKAGE(deal.II 8.0 REQUIRED - HINTS ${DEAL_II_DIR} ../ ../../ $ENV{DEAL_II_DIR} - ) - - DEAL_II_INITIALIZE_CACHED_VARIABLES() - PROJECT(step-1 CXX) - - ADD_EXECUTABLE(step-1 step-1.cc) - DEAL_II_SETUP_TARGET(step-1) -- TODO: Explain the two macros! - - TODO: Optionally, specify a run target: -
- - # (Optional) - # If you wish to have a "run" target for make, specify one: - ADD_CUSTOM_TARGET(run COMMAND step-1 - COMMENT "Run with ${CMAKE_BUILD_TYPE} configuration" - ) -- TODO: More in the next section - - +
+# (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} +) +
CMakeLists.txt
deal.IIConfig.cmake
file. Either by directly
specifying deal.II_DIR
to point to the path were the
deal.IIConfig.cmake
file is located:
+
+ TODO: is deal.II_DIR still accurate? We use different above
+
cmake -Ddeal.II_DIR=/path/to/the/config/file <...> diff --git a/deal.II/doc/screen.css b/deal.II/doc/screen.css index 65610cf281..5ca7aa3459 100644 --- a/deal.II/doc/screen.css +++ b/deal.II/doc/screen.css @@ -180,6 +180,16 @@ pre { line-height: 1.1em; } +pre.sample { + padding: 1em; + text-align: left; + text-indent: 0; + border: 1px dashed #2f6fab; + color: Black; + background-color: #f9f9f9; + line-height: 1.1em; +} + table.navbar { } table.tutorial { color: black; -- 2.39.5