

We just need to provide the my_library-config.cmake file. Set(MY_LIBRARY_VERSION $ - matches this expression. Set(MY_LIBRARY_VERSION_MINOR 0 CACHE STRING "minor version" FORCE) Right-click on CMake target with CMake Targets View active in the Solution Explorer and select Build from the context menu.

The project automatically builds first, just like a Visual Studio solution. Set(MY_LIBRARY_VERSION_MAJOR 1 CACHE STRING "major version" FORCE) Select the preferred target and press F5, or choose the Run button on the toolbar. # define library version (update: apparently you can also do it in project()!) If the install target is run then this also enables all built. The root CMakeLists.txt can look as follows: cmake_minimum_required(VERSION 3.0) This results in all of the (enabled) documentation targets being as part of a normal build. I can build and install all libraries and then build own code, but this isn't convenient. This allows a seperation of CMake’s config files and other, unrelated configuration macros etc. Installing Reaktoro after it has been built You may want to install Reaktoro in a directory of your choice after building it with cmake. Problem is to automate step 2 (need to trigger install target after addsubdiretory inside main project CMakeLists.txt). The configurations will be set in the file which will be preprocessed to config_impl.hpp and included by config.hpp. The root CMakeLists.txt defines configuration options and adds the subdirectories.

#Cmake install target code#
The library, the examples and the tool each has their own CMakeLists.txt defining the target and related code in their subdirectory. It also comes with some examples, a tool and unit tests. xml, registers the package with the ament index, and installs config (and possibly target) files for CMake so that it can be found by other packages using. So we have a library consisting of various header and source files. The setupįor the scope of the tutorial, let’s say we have a library that has the following CMake structure: - include/ Throughout this post, I’ll be assuming a 3.x CMake version and an already existing CMake project. In particular, the system will be able to handle multiple installed versions and multiple configurations.
#Cmake install target how to#
In this post, I will show you how to install your library so that it can be used easily by other projects. As of version 0.5 my memory library now provides support for system-wide installation and CMake’s find_package().īecause I’ve spent hours of trial and error to come up with it, I’ll document it here.
