OXIESEC PANEL
- Current Dir:
/
/
usr
/
local
/
doc
/
cmake
/
html
/
_sources
/
guide
/
tutorial
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
04/04/2023 07:10:48 PM
rwxr-xr-x
📄
A Basic Starting Point.rst.txt
12.93 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding Export Configuration.rst.txt
5.99 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding Generator Expressions.rst.txt
9.32 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding Support for a Testing Dashboard.rst.txt
3.15 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding System Introspection.rst.txt
4.71 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding Usage Requirements for a Library.rst.txt
4.46 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding a Custom Command and Generated File.rst.txt
3.62 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Adding a Library.rst.txt
12.31 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Installing and Testing.rst.txt
8.94 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Packaging Debug and Release.rst.txt
3.01 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Packaging an Installer.rst.txt
2.53 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
Selecting Static or Shared Libraries.rst.txt
3.12 KB
04/04/2023 07:03:28 PM
rw-r--r--
📄
index.rst.txt
1.13 KB
04/04/2023 07:03:28 PM
rw-r--r--
Editing: Packaging Debug and Release.rst.txt
Close
Step 12: Packaging Debug and Release ==================================== **Note:** This example is valid for single-configuration generators and will not work for multi-configuration generators (e.g. Visual Studio). By default, CMake's model is that a build directory only contains a single configuration, be it Debug, Release, MinSizeRel, or RelWithDebInfo. It is possible, however, to setup CPack to bundle multiple build directories and construct a package that contains multiple configurations of the same project. First, we want to ensure that the debug and release builds use different names for the libraries that will be installed. Let's use `d` as the postfix for the debug libraries. Set :variable:`CMAKE_DEBUG_POSTFIX` near the beginning of the top-level ``CMakeLists.txt`` file: .. literalinclude:: Complete/CMakeLists.txt :caption: CMakeLists.txt :name: CMakeLists.txt-CMAKE_DEBUG_POSTFIX-variable :language: cmake :start-after: project(Tutorial VERSION 1.0) :end-before: target_compile_features(tutorial_compiler_flags And the :prop_tgt:`DEBUG_POSTFIX` property on the tutorial executable: .. literalinclude:: Complete/CMakeLists.txt :caption: CMakeLists.txt :name: CMakeLists.txt-DEBUG_POSTFIX-property :language: cmake :start-after: # add the executable :end-before: # add the binary tree to the search path for include files Let's also add version numbering to the ``MathFunctions`` library. In ``MathFunctions/CMakeLists.txt``, set the :prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` properties: .. literalinclude:: Complete/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-VERSION-properties :language: cmake :start-after: # setup the version numbering :end-before: # install libs From the ``Step12`` directory, create ``debug`` and ``release`` subdirectories. The layout will look like: .. code-block:: none - Step12 - debug - release Now we need to setup debug and release builds. We can use :variable:`CMAKE_BUILD_TYPE` to set the configuration type: .. code-block:: console cd debug cmake -DCMAKE_BUILD_TYPE=Debug .. cmake --build . cd ../release cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . Now that both the debug and release builds are complete, we can use a custom configuration file to package both builds into a single release. In the ``Step12`` directory, create a file called ``MultiCPackConfig.cmake``. In this file, first include the default configuration file that was created by the :manual:`cmake <cmake(1)>` executable. Next, use the ``CPACK_INSTALL_CMAKE_PROJECTS`` variable to specify which projects to install. In this case, we want to install both debug and release. .. literalinclude:: Complete/MultiCPackConfig.cmake :caption: MultiCPackConfig.cmake :name: MultiCPackConfig.cmake :language: cmake From the ``Step12`` directory, run :manual:`cpack <cpack(1)>` specifying our custom configuration file with the ``config`` option: .. code-block:: console cpack --config MultiCPackConfig.cmake