"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <title>The deal.II Readme</title>
+ <title>deal.II CMake documentation</title>
<link href="../screen.css" rel="StyleSheet">
<meta name="author" content="the deal.II authors <authors @ dealii.org>">
<meta name="copyright" content="Copyright (C) 2012, 2013 by the deal.II authors">
<li><a href="#compiler">Selecting a compiler</a>
<li><a href="#configureinstall">Installation</a>
</ul>
- <li><a href="#ext">How to use deal.II in your CMake project</a>
- <ul>
- <li><a href="#extfinding">Finding the deal.II library</a>
- <li><a href="#extcmake">deal.IIConfig.cmake</a>
- <li><a href="#extsetup">Setting up necessary configuration variables</a>
- </ul>
<li><a href="#advanced">Initial cache file and advanced options</a>
<li><a href="#compiling">Compiling only certain parts</a>
</ul>
</p>
- <a name="ext"></a>
- <h3> How to use deal.II in your CMake project </h3>
-
- <p>
- Using <acronym>deal.II</acronym> in your own project is particularly
- simple if your project also uses <code>cmake</code>. The following
- subsections describe this process.
- </p>
-
-
- <a name="extfinding"></a>
- <h4> Finding the deal.II library </h4>
-
- <p>
- Finding the <acronym>deal.II</acronym> library should be no more than
- <pre>
-
- FIND_PACKAGE(deal.II REQUIRED)
- </pre>
- in your CMakeLists.txt file. You may have to hint for the location
- of the <code>deal.IIConfig.cmake</code> file. Either by directly
- specifying <code>deal.II_DIR</code> to point to the path were the
- <code>deal.IIConfig.cmake</code> file is located:
- <pre>
-
- cmake -Ddeal.II_DIR=/path/to/the/config/file <...>
- </pre>
- or by specifying a search path via <code>CMAKE_PREFIX_PATH</code>,
- e.g.
- <pre>
-
- cmake -DCMAKE_PREFIX_PATH=~/workspace/local
- </pre>
- In this case <code>deal.IIConfig.cmake</code> will be searched
- for in
- <pre>
-
- ~/workspace/local/
- ~/workspace/local/lib/cmake/deal.II/
- </pre>
- </p>
-
-
- <a name="extcmake"></a>
- <h4> deal.IIConfig.cmake </h4>
-
- <p>
- Importing the deal.IIConfig.cmake file via <code>FIND_PACKAGE</code>
- will set a bunch of variables and macros; all of the form
- <code>DEAL_II_*</code>. There is the usual duplet:
- <pre>
-
- DEAL_II_INCLUDE_DIRS
- DEAL_II_LIBRARIES
- </pre>
- (with <code>debug</code> and <code>optimized</code> keywords. For
- compatibility there is also <code>DEAL_II_LIBRARIES_DEBUG</code>
- and <code>DEAL_II_LIBRARIES_RELEASE</code> only specifying the
- respective set of libraries.)
- </p>
-
- <p>
- Interesting additional variables might be:
- <pre>
-
- 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
- </pre>
- </p>
-
-
-
- <a name="extsetup"></a>
- <h4> Setting up necessary configuration variables </h4>
-
- <p>
- For actually using <acronym>deal.II</acronym> in your CMake
- project some configuration steps are necessary. These can be
- either set via <a href="#extsetupmacro">macros</a> or by <a
- href="#extsetuphand">hand</a>:
- <ol>
- <a name="extsetupmacro"></a><li> <b>Configuration with the help of
- two convencience macros:</b>
- <p>
- <code>deal.IIConfig.cmake</code> includes some convenience macros
- to automatically setup all necessary configuration. A fully
- functional, minimal example for the step-1 tutorial program is:
- <pre>
-
- 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)
- </pre>
- </p>
-
-
- <a name="extsetuphand"></a><li> <b>Configuration by hand:</b>
- <ul>
- <li> Set up all include directories for header files:
- <pre>
-
- INCLUDE_DIRECTORIES(${DEAL_II_INCLUDE_DIRS})
- </pre>
-
- <li>
- deal.II usually ships with an optimized Release and a Debug version
- of the library. So it is a good idea to set up
- <code>CMAKE_BUILD_TYPE</code> accordingly:
- <pre>
-
- SET(CMAKE_BUILD_TYPE "Debug" CACHE
- "Choose the type of build, options are: Debug, Release"
- )
- </pre>
-
- A cached variable ensures that we can later switch the build type
- by editing the cache:
- <pre>
-
- make edit_cache
- </pre>
-
- <li> Often, it is a good idea to use the same compiler and linker
- flags as the deal.II library.
- <pre>
-
- 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})
- </pre>
- (Optionally you can set up the variables with the
- <code>CACHE</code> to be able to edit them via ccmake or
- make edit_cache.)
-
- <li>
- <i>After</i> this, specify your project name:
- <pre>
-
- PROJECT(myProject)
- </pre>
- This ensures that the compiler detection and platform setup
- that is issued by calling <code>PROJECT(...)</code> 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 <code>PROJECT(...)</code> call.
-
- <li>
- After defining your targets, e.g.
- <pre>
-
- ADD_EXECUTABLE(step-1 step-1.cc)
- </pre>
- you have to specify to link against deal.II and all external
- libraries:
- <pre>
-
- TARGET_LINK_LIBRARIES(step-1 ${DEAL_II_LIBRARIES})
- </pre>
-
- <li> as well as using some preprocessor definitions:
- <pre>
-
- 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}"
- )
- </pre>
-
- <li> Optionally, you can set the link flags to the one used by the
- deal.II library:
- <pre>
-
- 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}"
- )
- </pre>
- And this it is.
-
- </ul>
-
- <li>
- <b>Advanced setup:</b>
-
- <p>
- For an advanced setup in a big CMake project
- <code><a href="#extcmake">deal.IIConfig.cmake</a></code>
- provides information about the <acronym>deal.II</acronym>
- installation with traditional variables, see
- <a href="#extcmake">here</a>, as well as <i>external CMake
- targets</i> with link interface for direct inclusion:
- <pre>
-
- INCLUDE(${DEAL_II_TARGET_CONFIG})
-
- ADD_EXECUTABLE(step-1
- step-1.cc
- ${DEAL_II_TARGET}
- )
- </pre>
- </p>
- </ol>
- </p>
-
-
<a name="advanced"></a>
<h3>Initial cache file and advanced options</h3>
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
- <title>Information on using CMake for deal.II projects</title>
+ <title>How to interface with deal.II in your own project</title>
<link href="../screen.css" rel="StyleSheet">
<meta name="author" content="the deal.II authors <authors @ dealii.org>">
<meta name="copyright" content="Copyright (C) 2012, 2013 by the deal.II authors">
<tr><th colspan="2"><b><small>Table of contents</small></b></th></tr>
<tr><td valign="top">
<ul>
- <li><a href="#cmake">Using <acronym>deal.II</acronym> in a
- CMake project</a>
+ <li><a href="#cmake">Example <code>CMakeLists.txt</code> files</a>
<ul>
- <li><a href="#cmakesimple">Simple CMakeLists.txt</a>
- <li><a href="#cmakeadvanced">Advanced CMakeLists.txt</a>
+ <li><a href="#cmakesimple">Simple <code>CMakeLists.txt</code></a>
+ <li><a href="#cmakeadvanced">Advanced <code>CMakeLists.txt</code></a>
+ </ul>
+ <li><a href="#ext">Advanced setup for <acronym>deal.II</acronym> in a CMake project</a>
+ <ul>
+ <li><a href="#extfinding">Finding the deal.II library</a>
+ <li><a href="#extcmake">deal.IIConfig.cmake</a>
+ <li><a href="#extsetup">Setting up necessary configuration variables</a>
</ul>
<li><a href="#legacy">Legacy
<code>Make.global_options</code></a>
<a name="cmake"></a>
- <h3> Using <acronym>deal.II</acronym> in a CMake project </h3>
+ <h3> Example <code>CMakeLists.txt</code> files </h3>
<p>
<code>cmake</code> is the configuration and build tool we use
target="body">deal.II CMake ReadME</a>.
</p>
+
+
+ <a name="ext"></a>
+ <h3> Advanced setup for <acronym>deal.II</acronym> in a CMake project </h3>
+
+ <a name="extfinding"></a>
+ <h4> Finding the deal.II library </h4>
+
+ <p>
+ Finding the <acronym>deal.II</acronym> library should be no more than
+ <pre>
+
+ FIND_PACKAGE(deal.II REQUIRED)
+ </pre>
+ in your CMakeLists.txt file. You may have to hint for the location
+ of the <code>deal.IIConfig.cmake</code> file. Either by directly
+ specifying <code>deal.II_DIR</code> to point to the path were the
+ <code>deal.IIConfig.cmake</code> file is located:
+ <pre>
+
+ cmake -Ddeal.II_DIR=/path/to/the/config/file <...>
+ </pre>
+ or by specifying a search path via <code>CMAKE_PREFIX_PATH</code>,
+ e.g.
+ <pre>
+
+ cmake -DCMAKE_PREFIX_PATH=~/workspace/local
+ </pre>
+ In this case <code>deal.IIConfig.cmake</code> will be searched
+ for in
+ <pre>
+
+ ~/workspace/local/
+ ~/workspace/local/lib/cmake/deal.II/
+ </pre>
+ </p>
+
+
+ <a name="extcmake"></a>
+ <h4> deal.IIConfig.cmake </h4>
+
+ <p>
+ Importing the deal.IIConfig.cmake file via <code>FIND_PACKAGE</code>
+ will set a bunch of variables and macros; all of the form
+ <code>DEAL_II_*</code>. There is the usual duplet:
+ <pre>
+
+ DEAL_II_INCLUDE_DIRS
+ DEAL_II_LIBRARIES
+ </pre>
+ (with <code>debug</code> and <code>optimized</code> keywords. For
+ compatibility there is also <code>DEAL_II_LIBRARIES_DEBUG</code>
+ and <code>DEAL_II_LIBRARIES_RELEASE</code> only specifying the
+ respective set of libraries.)
+ </p>
+
+ <p>
+ Interesting additional variables might be:
+ <pre>
+
+ 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
+ </pre>
+ </p>
+
+
+
+ <a name="extsetup"></a>
+ <h4> Setting up necessary configuration variables </h4>
+
+ <p>
+ For actually using <acronym>deal.II</acronym> in your CMake
+ project some configuration steps are necessary. These can be
+ either set via <a href="#extsetupmacro">macros</a> or by <a
+ href="#extsetuphand">hand</a>:
+ <ol>
+ <a name="extsetupmacro"></a><li> <b>Configuration with the help of
+ two convencience macros:</b>
+ <p>
+ <code>deal.IIConfig.cmake</code> includes some convenience macros
+ to automatically setup all necessary configuration. A fully
+ functional, minimal example for the step-1 tutorial program is:
+ <pre>
+
+ 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)
+ </pre>
+ </p>
+
+
+ <a name="extsetuphand"></a><li> <b>Configuration by hand:</b>
+ <ul>
+ <li> Set up all include directories for header files:
+ <pre>
+
+ INCLUDE_DIRECTORIES(${DEAL_II_INCLUDE_DIRS})
+ </pre>
+
+ <li>
+ deal.II usually ships with an optimized Release and a Debug version
+ of the library. So it is a good idea to set up
+ <code>CMAKE_BUILD_TYPE</code> accordingly:
+ <pre>
+
+ SET(CMAKE_BUILD_TYPE "Debug" CACHE
+ "Choose the type of build, options are: Debug, Release"
+ )
+ </pre>
+
+ A cached variable ensures that we can later switch the build type
+ by editing the cache:
+ <pre>
+
+ make edit_cache
+ </pre>
+
+ <li> Often, it is a good idea to use the same compiler and linker
+ flags as the deal.II library.
+ <pre>
+
+ 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})
+ </pre>
+ (Optionally you can set up the variables with the
+ <code>CACHE</code> to be able to edit them via ccmake or
+ make edit_cache.)
+
+ <li>
+ <i>After</i> this, specify your project name:
+ <pre>
+
+ PROJECT(myProject)
+ </pre>
+ This ensures that the compiler detection and platform setup
+ that is issued by calling <code>PROJECT(...)</code> 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 <code>PROJECT(...)</code> call.
+
+ <li>
+ After defining your targets, e.g.
+ <pre>
+
+ ADD_EXECUTABLE(step-1 step-1.cc)
+ </pre>
+ you have to specify to link against deal.II and all external
+ libraries:
+ <pre>
+
+ TARGET_LINK_LIBRARIES(step-1 ${DEAL_II_LIBRARIES})
+ </pre>
+
+ <li> as well as using some preprocessor definitions:
+ <pre>
+
+ 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}"
+ )
+ </pre>
+
+ <li> Optionally, you can set the link flags to the one used by the
+ deal.II library:
+ <pre>
+
+ 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}"
+ )
+ </pre>
+ And this it is.
+
+ </ul>
+
+ <li>
+ <b>Exported targets:</b>
+
+ <p>
+ For an advanced setup in a big CMake project
+ <code><a href="#extcmake">deal.IIConfig.cmake</a></code>
+ provides information about the <acronym>deal.II</acronym>
+ installation with traditional variables, see
+ <a href="#extcmake">here</a>, as well as <i>external CMake
+ targets</i> with link interface for direct inclusion:
+ <pre>
+
+ INCLUDE(${DEAL_II_TARGET_CONFIG})
+
+ ADD_EXECUTABLE(step-1
+ step-1.cc
+ ${DEAL_II_TARGET}
+ )
+ </pre>
+ </p>
+ </ol>
+ </p>
+
+
+
<a name="legacy"></a>
<h3> Legacy Make.global_options </h3>
<li> <p>
<a href="cmake.html">deal.II CMake documentation</a>:
- This page provides extensive information about usage
- of the <acronym>deal.II</acronym> CMake build system.
-
- <li> <p><a href="cmakelists.html" target="body">Example CMakeLists.txt</a>:
- An overview of how to write the <code>CMakeLists.txt</code> input
- files that control <code>cmake</code> if you want to use it for your
- own project and want it to compile and link against
- the <acronym>deal.II</acronym> library.
+ This page provides extensive information about configuration and
+ installation with the CMake build system.
+
+ <li> <p><a href="cmakelists.html" target="body">Using
+ <acronym>deal.II</acronym> in a user project</a>:
+ This page covers how to use CMake in your own project.
+ An overview of how to retrieve necessary information
+ from a <acronym>deal.II</acronym> installation as well as how to
+ write a <code>CMakeLists.txt</code> for a client project is given.
</p>
<li> <p>
<a href="cmake-internals.html">deal.II CMake internals</a>:
- This page provides details about <acronym>deal.II</acronym> CMake
- build system.
+ This page provides implementation and development details about
+ the CMake build system.
<li> <p><a href="writing-documentation.html" target="body">Writing
documentation</a>: To document the library and our