forked from mysql/mysql-connector-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PackageSpecs.cmake
208 lines (165 loc) · 7.13 KB
/
PackageSpecs.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License, version 2.0, as
# published by the Free Software Foundation.
#
# This program is also distributed with certain software (including
# but not limited to OpenSSL) that is licensed under separate terms,
# as designated in a particular file or component or in included license
# documentation. The authors of MySQL hereby grant you an
# additional permission to link the program and your derivative works
# with the separately licensed software that they have included with
# MySQL.
#
# Without limiting anything contained in the foregoing, this file,
# which is part of MySQL Connector/C++, is also subject to the
# Universal FOSS Exception, version 1.0, a copy of which can be found at
# http://oss.oracle.com/licenses/universal-foss-exception.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License, version 2.0, for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Specifications for Connector/C++ binary and source packages
#
# TODO
# - Generate HTML docs with Doxygen and include in bin packages
#
# Note: CPACK_XXX variables must be set before include(CPack)
#
# ======================================================================
# Set some initial CPack variables
# ======================================================================
set(CPACK_PACKAGE_NAME "mysql-connector-c++")
set(CPACK_PACKAGE_VERSION "${CONCPP_PACKAGE_VERSION}")
set(CPACK_PACKAGE_VENDOR "Oracle Corporation")
set(CPACK_PACKAGE_CONTACT "MySQL Release Engineering <[email protected]>")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"MySQL Connector/C++, a C++ connector library")
# ======================================================================
# Set the default CPack generator
# ======================================================================
if(WIN32)
set(CPACK_GENERATOR ZIP)
set(CPACK_SOURCE_GENERATOR ZIP)
else()
set(CPACK_GENERATOR TGZ)
set(CPACK_SOURCE_GENERATOR TGZ)
endif()
# ======================================================================
# Set the platform name, if not set from -DPLATFORM_NAME=...
# ======================================================================
#
# TODO: Cover Windows and other architectures we suport
#
# TODO: Decide on proper tagging for Windows: VS version, static/dynamic
# runtime, debug/non-debug etc. Note: some of these differences can/should
# be covered by having several variants of the library added to the package.
if(PLATFORM_NAME)
# Override with our own name
set(CPACK_SYSTEM_NAME "${PLATFORM_NAME}")
elseif(WIN32)
include(CheckTypeSize)
if(CMAKE_SIZEOF_VOID_P MATCHES 8)
set(CPACK_SYSTEM_NAME "winx64")
else()
set(CPACK_SYSTEM_NAME "win32")
endif()
elseif(APPLE)
if(NOT DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
message(FATAL_ERROR "To create packages on OSX, set deployment target"
" using MACOSX_DEPLOYMENT_TARGET environment variable")
endif()
set(osx_version $ENV{MACOSX_DEPLOYMENT_TARGET})
set(CPACK_SYSTEM_NAME "osx${osx_version}-${CMAKE_SYSTEM_PROCESSOR}")
elseif(NOT CPACK_SYSTEM_NAME)
# If for some reason not set by CMake
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_SYSTEM_NAME "linux-${CMAKE_SYSTEM_PROCESSOR}")
else()
message(FATAL_ERROR "Can't deternine how to set the platform name")
endif()
endif()
IF(EXTRA_NAME_SUFFIX)
SET(CPACK_PACKAGE_NAME "mysql-connector-c++${EXTRA_NAME_SUFFIX}")
ELSE(EXTRA_NAME_SUFFIX)
SET(CPACK_PACKAGE_NAME "mysql-connector-c++")
ENDIF(EXTRA_NAME_SUFFIX)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_TOPLEVEL_TAG "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
if(CMAKE_BUILD_TYPE STREQUAL Debug)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}-debug")
endif()
message("Binary package name: ${CPACK_PACKAGE_FILE_NAME}")
# FIXME maybe place elsewhere?
if(APPLE AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(FATAL_ERROR "To create packages for OSX, build with clang compiler.")
endif()
# ======================================================================
# Licenses for binary packages
# ======================================================================
if(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE.mysql.txt")
set(LIC_FILE "LICENSE.mysql") # Without ".txt" extension
else()
set(LIC_FILE "LICENSE") # Without ".txt" extension
endif()
if(WIN32)
set(info_ext ".txt")
set(newline WIN32)
else()
set(info_ext "")
set(newline UNIX)
endif()
set(info_files README ${LIC_FILE})
foreach(file ${info_files})
set(file_src "${CMAKE_SOURCE_DIR}/${file}.txt")
set(file_bin "${CMAKE_BINARY_DIR}/${file}${info_ext}")
configure_file("${file_src}" "${file_bin}" NEWLINE_STYLE ${newline})
install(FILES "${file_bin}" DESTINATION ${INSTALL_DOC_DIR} COMPONENT Readme)
endforeach()
set(CPACK_RESOURCE_FILE_README "README${info_ext}")
set(CPACK_RESOURCE_FILE_LICENSE "${LIC_FILE}${info_ext}")
#set(CPACK_RESOURCE_FILE_INSTALL "...") # FIXME
# ======================================================================
# Specs for source package
# ======================================================================
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-src")
message("Source package name: ${CPACK_SOURCE_PACKAGE_FILE_NAME}")
# note: Using regex patterns for CPACK_SOURCE_IGNORE_FILES is fragile because
# they are matched against the full path which can vary depending on where the
# build takes place. Unfortunatelly, I (Rafal) could not find any other mechanism
# for specifying what source files should be excluded from the source package.
#
# note: Double escaping required to get correct pattern string (with single
# escapes) in CPackSourceConfig.cmake
list(APPEND CPACK_SOURCE_IGNORE_FILES "\\\\.git.*")
list(APPEND CPACK_SOURCE_IGNORE_FILES "/jenkins/")
list(APPEND CPACK_SOURCE_IGNORE_FILES "CTestConfig.cmake")
include(CPack)
# ======================================================================
# Custom target to build packages.
# ======================================================================
add_custom_target(build_packages
COMMAND cpack --config CPackConfig.cmake --verbose -C $<CONFIGURATION>
COMMAND cpack --config CPackSourceConfig.cmake
DEPENDS clean_source_tree
)
add_custom_target(clean_source_tree
COMMAND git clean -x -d -f
COMMAND git submodule foreach --recursive git clean -x -d -f
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
COMMENT "Cleaning source tree"
)
set_property(TARGET clean_source_tree build_packages
PROPERTY EXCLUDE_FROM_ALL 1
)
set_property(TARGET clean_source_tree build_packages
PROPERTY EXCLUDE_FROM_DEFAULT_BUILD 1
)