directions.txt 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Building an Installer #
  2. Next suppose that we want to distribute our project to other people so that they
  3. can use it. We want to provide both binary and source distributions on a variety
  4. of platforms. This is a little different from the install we did previously in
  5. the Installing and Testing section (Step 4), where we were installing the
  6. binaries that we had built from the source code. In this example we will be
  7. building installation packages that support binary installations and package
  8. management features. To accomplish this we will use CPack to create platform
  9. specific installers. Specifically we need to add a few lines to the bottom of
  10. our top-level CMakeLists.txt file.
  11. include(InstallRequiredSystemLibraries)
  12. set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
  13. set(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
  14. set(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
  15. include(CPack)
  16. That is all there is to it. We start by including InstallRequiredSystemLibraries.
  17. This module will include any runtime libraries that are needed by the project
  18. for the current platform. Next we set some CPack variables to where we have
  19. stored the license and version information for this project. The version
  20. information makes use of the variables we set earlier in this tutorial. Finally
  21. we include the CPack module which will use these variables and some other
  22. properties of the system you are on to setup an installer.
  23. The next step is to build the project in the usual manner and then run CPack
  24. on it. To build a binary distribution you would run:
  25. cpack
  26. To create a source distribution you would type:
  27. cpack -C CPackSourceConfig.cmake
  28. Alternatively, run “make package” or right click the Package target and
  29. “Build Project” from an IDE.
  30. Run the installer executable found in the binary directory. Then run the
  31. installed executable and verify that it works.