From 88445798c562b62eb4ff9a7ac8eaebd16d0d55b4 Mon Sep 17 00:00:00 2001
From: maier
- Using deal.II in your own project is particularly
- simple if your project also uses cmake
. The following
- subsections describe this process.
-
- Finding the deal.II library should be no more than -
- - FIND_PACKAGE(deal.II REQUIRED) -- in your CMakeLists.txt file. You may have to hint for the location - of the
deal.IIConfig.cmake
file. Either by directly
- specifying deal.II_DIR
to point to the path were the
- deal.IIConfig.cmake
file is located:
- - - cmake -Ddeal.II_DIR=/path/to/the/config/file <...> -- or by specifying a search path via
CMAKE_PREFIX_PATH
,
- e.g.
- - - cmake -DCMAKE_PREFIX_PATH=~/workspace/local -- In this case
deal.IIConfig.cmake
will be searched
- for in
- - - ~/workspace/local/ - ~/workspace/local/lib/cmake/deal.II/ -- - - - -
- Importing the deal.IIConfig.cmake file via FIND_PACKAGE
- will set a bunch of variables and macros; all of the form
- DEAL_II_*
. There is the usual duplet:
-
- - DEAL_II_INCLUDE_DIRS - DEAL_II_LIBRARIES -- (with
debug
and optimized
keywords. For
- compatibility there is also DEAL_II_LIBRARIES_DEBUG
- and DEAL_II_LIBRARIES_RELEASE
only specifying the
- respective set of libraries.)
-
-
- - Interesting additional variables might be: -
- - DEAL_II_USER_DEFINITIONS - DEAL_II_USER_DEFINITIONS_DEBUG - DEAL_II_USER_DEFINITIONS_RELEASE - DEAL_II_LINKER_FLAGS - DEAL_II_LINKER_FLAGS_DEBUG - DEAL_II_LINKER_FLAGS_RELEASE - DEAL_II_CXX_FLAGS - DEAL_II_CXX_FLAGS_DEBUG - DEAL_II_CXX_FLAGS_RELEASE - - DEAL_II_TARGET_CONFIG - DEAL_II_TARGET - DEAL_II_TARGET_DEBUG - DEAL_II_TARGET_RELEASE -- - - - - -
- For actually using deal.II in your CMake - project some configuration steps are necessary. These can be - either set via macros or by hand: -
- deal.IIConfig.cmake
includes some convenience macros
- to automatically setup all necessary configuration. A fully
- functional, minimal example for the step-1 tutorial program is:
-
- - FIND_PACKAGE(deal.II REQUIRED) - - DEAL_II_INITIALIZE_CACHED_VARIABLES() - - PROJECT(step-1) - - ADD_EXECUTABLE(step-1 step-1.cc) - DEAL_II_SETUP_TARGET(step-1) -- - - -
- - INCLUDE_DIRECTORIES(${DEAL_II_INCLUDE_DIRS}) -- -
CMAKE_BUILD_TYPE
accordingly:
- - - SET(CMAKE_BUILD_TYPE "Debug" CACHE - "Choose the type of build, options are: Debug, Release" - ) -- - A cached variable ensures that we can later switch the build type - by editing the cache: -
- - make edit_cache -- -
- - SET(CMAKE_CXX_FLAGS ${DEAL_II_CXX_FLAGS}) - SET(CMAKE_CXX_FLAGS_RELEASE ${DEAL_II_CXX_FLAGS_RELEASE}) - SET(CMAKE_CXX_FLAGS_DEBUG ${DEAL_II_CXX_FLAGS_DEBUG}) -- (Optionally you can set up the variables with the -
CACHE
to be able to edit them via ccmake or
- make edit_cache.)
-
- - - PROJECT(myProject) -- This ensures that the compiler detection and platform setup - that is issued by calling
PROJECT(...)
will run
- after we have set up our cached variables. This way it is
- our choice of variables that will be set and not the default
- values determined by the PROJECT(...)
call.
-
- - - ADD_EXECUTABLE(step-1 step-1.cc) -- you have to specify to link against deal.II and all external - libraries: -
- - TARGET_LINK_LIBRARIES(step-1 ${DEAL_II_LIBRARIES}) -- -
- - SET_TARGET_PROPERTIES(step-1 PROPERTIES - COMPILE_DEFINITIONS - "${DEAL_II_USER_DEFINITIONS}" - COMPILE_DEFINITIONS_DEBUG - "${DEAL_II_USER_DEFINITIONS_DEBUG}" - COMPILE_DEFINITIONS_RELEASE - "${DEAL_II_USER_DEFINITIONS_RELEASE}" - ) -- -
- - SET_TARGET_PROPERTIES(step-1 PROPERTIES - LINK_FLAGS - "${DEAL_II_LINKER_FLAGS}" - LINK_FLAGS_DEBUG - "${DEAL_II_LINKER_FLAGS_DEBUG}" - LINK_FLAGS_RELEASE - "${DEAL_II_LINKER_FLAGS_RELEASE}" - ) -- And this it is. - -
- For an advanced setup in a big CMake project
- deal.IIConfig.cmake
- provides information about the deal.II
- installation with traditional variables, see
- here, as well as external CMake
- targets with link interface for direct inclusion:
-
- - INCLUDE(${DEAL_II_TARGET_CONFIG}) - - ADD_EXECUTABLE(step-1 - step-1.cc - ${DEAL_II_TARGET} - ) -- -
CMakeLists.txt
files
+ Make.global_options
@@ -37,7 +42,7 @@
- CMakeLists.txt
files
cmake
is the configuration and build tool we use
@@ -244,6 +249,232 @@
target="body">deal.II CMake ReadME.
+ Finding the deal.II library should be no more than +
+ + FIND_PACKAGE(deal.II REQUIRED) ++ in your CMakeLists.txt file. You may have to hint for the location + of the
deal.IIConfig.cmake
file. Either by directly
+ specifying deal.II_DIR
to point to the path were the
+ deal.IIConfig.cmake
file is located:
+ + + cmake -Ddeal.II_DIR=/path/to/the/config/file <...> ++ or by specifying a search path via
CMAKE_PREFIX_PATH
,
+ e.g.
+ + + cmake -DCMAKE_PREFIX_PATH=~/workspace/local ++ In this case
deal.IIConfig.cmake
will be searched
+ for in
+ + + ~/workspace/local/ + ~/workspace/local/lib/cmake/deal.II/ ++ + + + +
+ Importing the deal.IIConfig.cmake file via FIND_PACKAGE
+ will set a bunch of variables and macros; all of the form
+ DEAL_II_*
. There is the usual duplet:
+
+ + DEAL_II_INCLUDE_DIRS + DEAL_II_LIBRARIES ++ (with
debug
and optimized
keywords. For
+ compatibility there is also DEAL_II_LIBRARIES_DEBUG
+ and DEAL_II_LIBRARIES_RELEASE
only specifying the
+ respective set of libraries.)
+
+
+ + Interesting additional variables might be: +
+ + DEAL_II_USER_DEFINITIONS + DEAL_II_USER_DEFINITIONS_DEBUG + DEAL_II_USER_DEFINITIONS_RELEASE + DEAL_II_LINKER_FLAGS + DEAL_II_LINKER_FLAGS_DEBUG + DEAL_II_LINKER_FLAGS_RELEASE + DEAL_II_CXX_FLAGS + DEAL_II_CXX_FLAGS_DEBUG + DEAL_II_CXX_FLAGS_RELEASE + + DEAL_II_TARGET_CONFIG + DEAL_II_TARGET + DEAL_II_TARGET_DEBUG + DEAL_II_TARGET_RELEASE ++ + + + + +
+ For actually using deal.II in your CMake + project some configuration steps are necessary. These can be + either set via macros or by hand: +
+ deal.IIConfig.cmake
includes some convenience macros
+ to automatically setup all necessary configuration. A fully
+ functional, minimal example for the step-1 tutorial program is:
+
+ + FIND_PACKAGE(deal.II REQUIRED) + + DEAL_II_INITIALIZE_CACHED_VARIABLES() + + PROJECT(step-1) + + ADD_EXECUTABLE(step-1 step-1.cc) + DEAL_II_SETUP_TARGET(step-1) ++ + + +
+ + INCLUDE_DIRECTORIES(${DEAL_II_INCLUDE_DIRS}) ++ +
CMAKE_BUILD_TYPE
accordingly:
+ + + SET(CMAKE_BUILD_TYPE "Debug" CACHE + "Choose the type of build, options are: Debug, Release" + ) ++ + A cached variable ensures that we can later switch the build type + by editing the cache: +
+ + make edit_cache ++ +
+ + SET(CMAKE_CXX_FLAGS ${DEAL_II_CXX_FLAGS}) + SET(CMAKE_CXX_FLAGS_RELEASE ${DEAL_II_CXX_FLAGS_RELEASE}) + SET(CMAKE_CXX_FLAGS_DEBUG ${DEAL_II_CXX_FLAGS_DEBUG}) ++ (Optionally you can set up the variables with the +
CACHE
to be able to edit them via ccmake or
+ make edit_cache.)
+
+ + + PROJECT(myProject) ++ This ensures that the compiler detection and platform setup + that is issued by calling
PROJECT(...)
will run
+ after we have set up our cached variables. This way it is
+ our choice of variables that will be set and not the default
+ values determined by the PROJECT(...)
call.
+
+ + + ADD_EXECUTABLE(step-1 step-1.cc) ++ you have to specify to link against deal.II and all external + libraries: +
+ + TARGET_LINK_LIBRARIES(step-1 ${DEAL_II_LIBRARIES}) ++ +
+ + SET_TARGET_PROPERTIES(step-1 PROPERTIES + COMPILE_DEFINITIONS + "${DEAL_II_USER_DEFINITIONS}" + COMPILE_DEFINITIONS_DEBUG + "${DEAL_II_USER_DEFINITIONS_DEBUG}" + COMPILE_DEFINITIONS_RELEASE + "${DEAL_II_USER_DEFINITIONS_RELEASE}" + ) ++ +
+ + SET_TARGET_PROPERTIES(step-1 PROPERTIES + LINK_FLAGS + "${DEAL_II_LINKER_FLAGS}" + LINK_FLAGS_DEBUG + "${DEAL_II_LINKER_FLAGS_DEBUG}" + LINK_FLAGS_RELEASE + "${DEAL_II_LINKER_FLAGS_RELEASE}" + ) ++ And this it is. + +
+ For an advanced setup in a big CMake project
+ deal.IIConfig.cmake
+ provides information about the deal.II
+ installation with traditional variables, see
+ here, as well as external CMake
+ targets with link interface for direct inclusion:
+
+ + INCLUDE(${DEAL_II_TARGET_CONFIG}) + + ADD_EXECUTABLE(step-1 + step-1.cc + ${DEAL_II_TARGET} + ) ++ +
deal.II CMake documentation: - This page provides extensive information about usage - of the deal.II CMake build system. - -
Example CMakeLists.txt:
- An overview of how to write the CMakeLists.txt
input
- files that control cmake
if you want to use it for your
- own project and want it to compile and link against
- the deal.II library.
+ This page provides extensive information about configuration and
+ installation with the CMake build system.
+
+
Using
+ deal.II in a user project:
+ This page covers how to use CMake in your own project.
+ An overview of how to retrieve necessary information
+ from a deal.II installation as well as how to
+ write a CMakeLists.txt
for a client project is given.
deal.II CMake internals: - This page provides details about deal.II CMake - build system. + This page provides implementation and development details about + the CMake build system.
Writing documentation: To document the library and our -- 2.39.5