-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeCPack.cmake
122 lines (105 loc) · 5.37 KB
/
CMakeCPack.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
include(SupportedOs)
get_cmake_property(CPACK_COMPONENTS_ALL COMPONENTS)
message(STATUS "component to install: ${CPACK_COMPONENTS_ALL}")
# configuration part
file(WRITE
"${PROJECT_BINARY_DIR}/packaging/DESCRIPTION.txt"
${ODOX_PACKAGE_DESCRIPTION_LIST}
)
string(TOLOWER "${PROJECT_NAME}" __lower_project_name__)
git_commits(WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}" VARIABLE __package_release__)
string(TOLOWER "${CMAKE_HOST_SYSTEM_NAME}" __lower_host_system_name__)
# common section
set(CPACK_PACKAGE_VENDOR "Giampiero Gabbiani <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_DESCRIPTION}")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
if (CMAKE_BUILD_TYPE STREQUAL Release)
set(CPACK_STRIP_FILES TRUE)
else()
set(CPACK_STRIP_FILES FALSE)
endif()
message(STATUS "Packaged executable strip: ${CPACK_STRIP_FILES}")
# source generator
set(CPACK_SOURCE_GENERATOR "ZIP;TGZ")
# set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};/.git/;.gitignore;.vscode/")
set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_BINARY_DIR};.vscode/")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${__lower_project_name__}-${CPACK_PACKAGE_VERSION}-${__package_release__}")
list(APPEND CPACK_GENERATOR ${OS_CPACK})
os_package_file_name(
NAME ${__lower_project_name__}
VERSION ${CPACK_PACKAGE_VERSION}
RELEASE ${__package_release__}
VARIABLE CPACK_PACKAGE_FILE_NAME
)
message(STATUS "Package file name: '${CPACK_PACKAGE_FILE_NAME}'")
if (UNIX)
set(CPACK_PACKAGING_INSTALL_PREFIX "${OS_PACKAGE_INSTALL_PREFIX}")
if(CMAKE_SYSTEM_NAME MATCHES Linux)
message(STATUS "Detected Linux distro: '${DISTRO_ID}'")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_BINARY_DIR}/packaging/DESCRIPTION.txt")
if (DISTRO_ID STREQUAL debian OR DISTRO_ID STREQUAL ubuntu)
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${CPACK_PACKAGE_VENDOR}")
set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
elseif (DISTRO_ID STREQUAL fedora)
set(CPACK_RPM_PACKAGE_RELEASE ${__package_release__})
set(CPACK_RPM_PACKAGE_RELEASE_DIST ".fc${DISTRO_VERSION_ID}")
set(CPACK_RPM_PACKAGE_LICENSE "GPL-3.0-or-later")
# CPACK_RPM_PACKAGE_GROUP is deprecated on Fedora
set(CPACK_RPM_PACKAGE_GROUP Unspecified)
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
else()
message(AUTHOR_WARNING "Unmanaged distro id: ${DISTRO_ID}")
endif()
elseif(APPLE)
# post-flight.sh will add system-wide PATH env
set(__path_entry__ "${PROJECT_BINARY_DIR}/packaging/macos/100-orthodocs")
configure_file(packaging/macos/orthodocs-path.in "${__path_entry__}")
configure_file(packaging/macos/post-flight.sh.in packaging/macos/post-flight.sh @ONLY)
set(CPACK_POSTFLIGHT_RUNTIME_SCRIPT "${PROJECT_BINARY_DIR}/packaging/macos/post-flight.sh")
configure_file(
packaging/macos/INSTALL_NOTES.txt.in
"${PROJECT_BINARY_DIR}/packaging/macos/INSTALL_NOTES.txt"
@ONLY
)
configure_file(
packaging/macos/Welcome.txt.in
packaging/macos/Welcome.txt
@ONLY
)
# currently only .rtfd, .rtf, .html, and .txt files are allowed on macOS.
# to avoid a bad file extension error we rename the existing files accordingly
configure_file(
LICENSE
"${PROJECT_BINARY_DIR}/packaging/macos/LICENSE.txt"
COPYONLY
)
set(CPACK_RESOURCE_FILE_README "${PROJECT_BINARY_DIR}/packaging/macos/INSTALL_NOTES.txt" )
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_BINARY_DIR}/packaging/macos/LICENSE.txt" )
set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_BINARY_DIR}/packaging/macos/Welcome.txt" )
set(CPACK_PRODUCTBUILD_IDENTIFIER "org.gabbiani.${PROJECT_NAME}" )
# productbuild
set(CPACK_PRODUCTBUILD_IDENTIFIER "org.gabbiani.orthodocs")
endif()
message(STATUS "cpack-install prefix: '${CPACK_PACKAGING_INSTALL_PREFIX}'")
# WINDOWS
elseif(WIN32 OR MINGW)
set(CPACK_NSIS_PACKAGE_NAME "${PROJECT_NAME}" )
SET(CPACK_NSIS_INSTALL_ROOT "C:")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${OS_PACKAGE_INSTALL_PREFIX}")
set(CPACK_NSIS_MODIFY_PATH ON )
set(CPACK_NSIS_CONTACT "${CPACK_PACKAGE_VENDOR}" )
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON )
set(CPACK_NSIS_MENU_LINKS "https://github.com/ggabbiani/orthodocs" "${PROJECT_NAME} Web Site")
set(CPACK_NSIS_CONTACT "${CPACK_PACKAGE_VENDOR}")
# The display name string that appears in the Windows Apps & features in Control Panel
SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_NSIS_PACKAGE_NAME}")
set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${CPACK_NSIS_PACKAGE_NAME}")
message(STATUS "cpack-install prefix: '${CPACK_NSIS_INSTALL_ROOT}/${CPACK_PACKAGE_INSTALL_DIRECTORY}'")
endif()
message(STATUS "CPack generators: ${CPACK_GENERATOR}")
include(CPack)