CMakeLists.txt 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. # CPack Example: User-selectable Installation Components
  2. #
  3. # In this example, we have a simple library (mylib) with an example
  4. # application (mylibapp). We create a binary installer that allows
  5. # users to select which pieces will be installed: the example
  6. # application, the library binaries, and/or the header file.
  7. cmake_minimum_required(VERSION 2.6)
  8. project(CPackComponents)
  9. # Create the mylib library
  10. add_library(mylib mylib.cpp)
  11. # Create the mylibapp application
  12. add_executable(mylibapp mylibapp.cpp)
  13. target_link_libraries(mylibapp mylib)
  14. # Create installation targets. Note that we put each kind of file
  15. # into a different component via COMPONENT. These components will
  16. # be used to create the installation components.
  17. install(TARGETS mylib
  18. ARCHIVE
  19. DESTINATION lib
  20. COMPONENT libraries)
  21. install(TARGETS mylibapp
  22. RUNTIME
  23. DESTINATION bin
  24. COMPONENT applications)
  25. install(FILES mylib.h
  26. DESTINATION include
  27. COMPONENT headers)
  28. # CPack boilerplate for this project
  29. set(CPACK_PACKAGE_NAME "MyLib")
  30. set(CPACK_PACKAGE_VENDOR "CMake.org")
  31. set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "MyLib - CPack Component Installation Example")
  32. set(CPACK_PACKAGE_VERSION "1.0.0")
  33. set(CPACK_PACKAGE_VERSION_MAJOR "1")
  34. set(CPACK_PACKAGE_VERSION_MINOR "0")
  35. set(CPACK_PACKAGE_VERSION_PATCH "0")
  36. set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
  37. # Include CPack to introduce the appropriate targets
  38. include(CPack)
  39. # Installation types
  40. cpack_add_install_type(Full
  41. DISPLAY_NAME "Everything")
  42. cpack_add_install_type(Developer)
  43. # Component groups
  44. cpack_add_component_group(Runtime)
  45. cpack_add_component_group(Development
  46. EXPANDED
  47. DESCRIPTION "All of the tools you'll ever need to develop software")
  48. # Components
  49. cpack_add_component(applications
  50. DISPLAY_NAME "MyLib Application"
  51. DESCRIPTION "An extremely useful application that makes use of MyLib"
  52. GROUP Runtime
  53. INSTALL_TYPES Full)
  54. cpack_add_component(libraries
  55. DISPLAY_NAME "Libraries"
  56. DESCRIPTION "Static libraries used to build programs with MyLib"
  57. GROUP Development
  58. INSTALL_TYPES Developer Full)
  59. cpack_add_component(headers
  60. DISPLAY_NAME "C++ Headers"
  61. DESCRIPTION "C/C++ header files for use with MyLib"
  62. GROUP Development
  63. DEPENDS libraries
  64. INSTALL_TYPES Developer Full)