Skip to content

Commit

Permalink
Describe some CMake options
Browse files Browse the repository at this point in the history
  • Loading branch information
rafmudaf committed Oct 29, 2019
1 parent 3fe0340 commit 45b6a28
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/source/install/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,44 @@ The commands above are equivalent to having run this command the first time:
# Initial configuration in Debug mode with dynamic linking
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=ON
CMAKE_BUILD_TYPE
****************
This option allows to set the compiler optimization level and debug
information. The value and its effect are listed in the table below.

================== ================================================================================================================
CMAKE_BUILD_TYPE Effect
================== ================================================================================================================
Release ``-O3`` optimization level
RelWithDebInfo ``-O2`` optimization level with ``-g`` flag for debug info
Debug No optimization and `-g` flag for debug info; additional debugging flags: ``-fcheck=all -pedantic -fbacktrace``
================== ================================================================================================================

For best performance but longer compile time, use ``Release``. The next level,
``RelWithDebInfo`` provides comparable performance and much faster compile

This comment has been minimized.

Copy link
@sayerhs

sayerhs Oct 29, 2019

Contributor

RelWithDebInfo will add debugging symbols to the executable through -g flag. Also it will result in a bigger executable most likely compared to -O2 alone.

This comment has been minimized.

Copy link
@rafmudaf

rafmudaf Oct 29, 2019

Author Collaborator

Aside from taking up disk space, why does anyone care about executable size? Why does MinSizeRel option exist?

This comment has been minimized.

Copy link
@bjonkman

bjonkman Oct 30, 2019

Contributor

MinSizeRel uses optimization level O1, and according to Intel: "The O1 option may improve performance for applications with very large code size, many branches, and execution time not dominated by code within loops." Also, with Windows/Intel/Visual Studio, the Release optimization level is O2, not O3.

time. Finally, use ``Debug`` during active development to catch any programming
errors that would otherwise be handled by the compiler and to include debugging

This comment has been minimized.

Copy link
@sayerhs

sayerhs Oct 29, 2019

Contributor

Not sure what you mean by otherwise handled by the compiler? Did you mean resulting in runtime errors?

This comment has been minimized.

Copy link
@rafmudaf

rafmudaf Oct 29, 2019

Author Collaborator

Yes, runtime errors. For example, adding fcheck=all adds runtime checks that wouldn't otherwise be caught. I'll update this language. And thank you for reading through this!

symbols so that the executables can be parsed by a debugger.

This flag can be set with the following command:

.. code-block:: bash
cmake .. -DCMAKE_BUILD_TYPE=RelWithDebInfo
CMAKE_INSTALL_PREFIX
********************
This flag sets the location of the compiled binaries when the build
tool runs the ``install`` command. It should be a full path in a carefully
chosen location. The binaries will be copied into ``include``, ``lib``,
and ``bin`` subfolders under the value of this flag. The default is to
install binaries within the repository in a folder called ``install``.

This flag can be set with the following command:

.. code-block:: bash
cmake .. -DCMAKE_INSTALL_PREFIX="/usr/local/"
Setting the build tool
++++++++++++++++++++++
Expand Down

0 comments on commit 45b6a28

Please sign in to comment.