
- #CMAKE INSTALL MULTIPLE DESTINATIONS INSTALL#
- #CMAKE INSTALL MULTIPLE DESTINATIONS FULL#
- #CMAKE INSTALL MULTIPLE DESTINATIONS ZIP#
Sadly, CPACK_COMPONENTS_ALL ( and other useful CPack variables) can be set only on project configuration, not on cpack run. Here we go, AnotherLibrary wasn’t packed this time. _packages /package / ├── DEBIAN │ ├── control CPack : - package: /path/to/cmake-cpack-example/ _ packages/some-application_0.
#CMAKE INSTALL MULTIPLE DESTINATIONS INSTALL#
$ cpack -G DEB CPack : Create package using DEB CPack : Install projects CPack : - Install project: some-application CPack : - Install component: SomeLibrary CPack : - Install component: some-application CPack : Create package - CPACK_DEBIAN_PACKAGE_DEPENDS not set, the package will have no dependencies. DCPACK_COMPONENTS_ALL = "SomeLibrary some-application" \ $ cmake -G Ninja - DCMAKE_BUILD_TYPE = Release \ $ cd /path /to /cmake -cpack -example /build To check what components will get packed, you can print the CPACK_COMPONENTS_ALL variable: I don’t quite understand, what is going on here, but that’s how it worked for me. ) the COMPONENT value should go right after EXPORT, otherwise it kind of doesn’t apply or applies to something else?. It is important that in case of install(TARGETS. # these are cache variables, so they could be overwritten with -D, I put all that into a separate CMake module in the project ( /cmake/Packing.cmake): Then you just include a standard module named CPack into your project. So if you already have installation instructions in your project, then there is not much left for you to do.Īs a bare minimum, you need to set some variables for CPack, such as package name and the way you’d like components to be ( or not to be) grouped. Most of the work is done by install() statements.
#CMAKE INSTALL MULTIPLE DESTINATIONS FULL#
Let’s take the same project that was used as an example in the C++ library article, but make it slightly more complex: now it will have one more library ( just to increase the number of components in the project, the main application doesn’t even link to it).įor the reference, full project source code is available here. Additional complexity of the task was that I needed to make a package only for that library and not for the entire SDK. In my case I needed to make a deb package for one of the libraries of our SDK, so deb package format will be the main focus of this article. Instead of dealing with every single package format structure and requirements “manually”, you can let CPack handle all of them, so you’ll only need to worry about getting the actual package contents together.
#CMAKE INSTALL MULTIPLE DESTINATIONS ZIP#
Quite often it’s just a ZIP archive, but it can be also something more sophisticated, such as a package in one of the package management system formats, such as NuGet, RPM, deb and so on.ĬPack comes especially handy if you need to support more than one package format. The package is simply a “distribution unit” - something that you share with your users, or, in other words, what form your library/SDK/application is delivered in. While CMake handles building the project, CPack is responsible for making packages. This time I was tasked with creating a deb package for one of the libraries in our SDK.Īnd what would you know, CMake can handle packaging too - with CPack utility.ĬPack, like CMake itself, is a CLI program. Location but with a -C Release.Last time I needed to handle a C++ library project with CMake. Release mode would be executed from the same Mode use ctest -C Debug -VV from the binary directory

Visual Studio), the configuration type must be


Rebuild the application and then cd to the binary directory and run theĬtest executable: ctest -N and ctest -VV. Input, and expected results based on the passed arguments. Invocation of do_test, another test is added to the project with a name, Verifies that the computed square root is correct for given input. Lastly, we have a function called do_test that runs the application and This case, verifying that the usage message is printed when an incorrect number Property to verify that the output of the test contains certain strings. The next test makes use of the PASS_REGULAR_EXPRESSION test Otherwise crash, and has a zero return value. The first test simply verifies that the application runs, does not segfault or Enable_testing() # does the application run add_test( NAME Runs COMMAND Tutorial 25 ) # does the usage message work? add_test( NAME Usage COMMAND Tutorial ) set_tests_properties( Usage PROPERTIES PASS_REGULAR_EXPRESSION "Usage.*number" ) # define a function to simplify adding tests function( do_test target arg result ) add_test( NAME Comp $ ) endfunction() # do a bunch of result based tests do_test( Tutorial 4 "4 is 2" ) do_test( Tutorial 9 "9 is 3" ) do_test( Tutorial 5 "5 is 2.236" ) do_test( Tutorial 7 "7 is 2.645" ) do_test( Tutorial 25 "25 is 5" ) do_test( Tutorial - 25 "-25 is (-nan|nan|0)" ) do_test( Tutorial 0.0001 "0.0001 is 0.01" )
