Skip to content

Commit 411ec05

Browse files
committed
cmake: Build system refactoring.
1 parent 6b9d639 commit 411ec05

29 files changed

+3090
-807
lines changed

CMakeLists.txt

Lines changed: 209 additions & 562 deletions
Large diffs are not rendered by default.

PackageSpecs.cmake

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License, version 2.0, as
5+
# published by the Free Software Foundation.
6+
#
7+
# This program is also distributed with certain software (including
8+
# but not limited to OpenSSL) that is licensed under separate terms,
9+
# as designated in a particular file or component or in included license
10+
# documentation. The authors of MySQL hereby grant you an
11+
# additional permission to link the program and your derivative works
12+
# with the separately licensed software that they have included with
13+
# MySQL.
14+
#
15+
# Without limiting anything contained in the foregoing, this file,
16+
# which is part of MySQL Connector/C++, is also subject to the
17+
# Universal FOSS Exception, version 1.0, a copy of which can be found at
18+
# http://oss.oracle.com/licenses/universal-foss-exception.
19+
#
20+
# This program is distributed in the hope that it will be useful, but
21+
# WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23+
# See the GNU General Public License, version 2.0, for more details.
24+
#
25+
# You should have received a copy of the GNU General Public License
26+
# along with this program; if not, write to the Free Software Foundation, Inc.,
27+
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
29+
#
30+
# Specifications for Connector/C++ binary and source packages
31+
#
32+
# TODO
33+
# - Generate HTML docs with Doxygen and include in bin packages
34+
#
35+
# Note: CPACK_XXX variables must be set before include(CPack)
36+
#
37+
38+
SET(CPACK_PACKAGE_VERSION_MAJOR ${CONNECTOR_MAJOR})
39+
SET(CPACK_PACKAGE_VERSION_MINOR ${CONNECTOR_MINOR})
40+
SET(CPACK_PACKAGE_VERSION_PATCH ${CONNECTOR_PATCH})
41+
SET(CPACK_PACKAGE_RELEASE_TYPE "")
42+
43+
# Needed for CPACK configuraiton, used for file name construction. Thus leaving it as is
44+
IF(EXTRA_VERSION)
45+
SET(MYSQLCPPCONN_VERSION "${CONNECTOR_NUMERIC_VERSION}${EXTRA_VERSION}${CPACK_PACKAGE_RELEASE_TYPE}")
46+
ELSE(EXTRA_VERSION)
47+
SET(MYSQLCPPCONN_VERSION "${CONNECTOR_NUMERIC_VERSION}${CPACK_PACKAGE_RELEASE_TYPE}")
48+
ENDIF(EXTRA_VERSION)
49+
50+
51+
# This is needed by windows installer and for CPACK
52+
IF(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
53+
SET(LICENSE_FILENAME "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
54+
ELSE(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
55+
SET(LICENSE_FILENAME "${CMAKE_SOURCE_DIR}/LICENSE")
56+
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
57+
58+
# Creating file with version info that will be used for installer
59+
# We have to do this trick because of license filename that is looked in this CMAKE_SOURCE_DIR (installer's cmake is run separately)
60+
IF(WIN32)
61+
FILE(WRITE "${CMAKE_BINARY_DIR}/win/config.cmake" "SET(CONNECTOR_PRODUCT_VERSION ${CONNECTOR_VERSION})\n"
62+
"SET(LICENSE_FILENAME \"${LICENSE_FILENAME}\")\n")
63+
ENDIF(WIN32)
64+
65+
66+
#
67+
# ----------------------------------------------------------------------
68+
# Create package script
69+
# ----------------------------------------------------------------------
70+
71+
IF(NOT CONNECTOR_PLATFORM)
72+
IF(WIN32)
73+
IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
74+
SET(CONNECTOR_PLATFORM "winx64")
75+
ELSE(CMAKE_SIZEOF_VOID_P MATCHES 8)
76+
SET(CONNECTOR_PLATFORM "win32")
77+
ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8)
78+
ELSE(WIN32)
79+
SET(CONNECTOR_PLATFORM "unknown")
80+
ENDIF(WIN32)
81+
ENDIF(NOT CONNECTOR_PLATFORM)
82+
83+
#CPACK version variables are initialized in VersionInfo.cmake
84+
# Get the part of the package name for this product
85+
IF(MYSQL_SERVER_SUFFIX STREQUAL "-community")
86+
SET(CPACK_SERVER_SUFFIX "")
87+
ELSE(MYSQL_SERVER_SUFFIX STREQUAL "-community")
88+
SET(CPACK_SERVER_SUFFIX ${MYSQL_SERVER_SUFFIX})
89+
ENDIF(MYSQL_SERVER_SUFFIX STREQUAL "-community")
90+
91+
IF(EXTRA_NAME_SUFFIX)
92+
SET(CPACK_PACKAGE_NAME "mysql-connector-c++${EXTRA_NAME_SUFFIX}")
93+
ELSE(EXTRA_NAME_SUFFIX)
94+
SET(CPACK_PACKAGE_NAME "mysql-connector-c++")
95+
ENDIF(EXTRA_NAME_SUFFIX)
96+
97+
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
98+
"Connector/C++, a library for connecting to MySQL servers.")
99+
SET(CPACK_PACKAGE_VENDOR "Oracle and/or its affiliates")
100+
SET(CPACK_RPM_PACKAGE_DESCRIPTION
101+
"The MySQL Connector/C++ is a MySQL database connector for C++. The
102+
MySQL Driver for C++ can be used to connect to the MySQL Server from
103+
C++ applications. The MySQL Driver for C++ mimics the JDBC 4.0 API. It
104+
is recommended to use the connector with MySQL 5.1 or later. Note -
105+
its full functionality is not available when connecting to MySQL 5.0.
106+
The MySQL Driver for C++ cannot connect to MySQL 4.1 or earlier. MySQL
107+
is a trademark of ${CPACK_PACKAGE_VENDOR}
108+
109+
The MySQL software has Dual Licensing, which means you can use the MySQL
110+
software free of charge under the GNU General Public License
111+
(http://www.gnu.org/licenses/). You can also purchase commercial MySQL
112+
licenses from ${CPACK_PACKAGE_VENDOR} if you do not wish to be
113+
QLCPPCONN_VERSION
114+
in the manual for further info.")
115+
116+
SET(CPACK_RESOURCE_FILE_LICENSE "${LICENSE_FILENAME}")
117+
SET(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
118+
SET(CPACK_RESOURCE_FILE_INSTALL "${CMAKE_SOURCE_DIR}/INSTALL")
119+
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${MYSQLCPPCONN_VERSION}")
120+
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}-${MYSQLCPPCONN_VERSION}-${CONNECTOR_PLATFORM}")
121+
IF(WIN32)
122+
SET(CPACK_GENERATOR "ZIP")
123+
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-noinstall-${MYSQLCPPCONN_VERSION}-${CONNECTOR_PLATFORM}")
124+
ELSE(WIN32)
125+
SET(CPACK_GENERATOR "TGZ")
126+
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
127+
ENDIF(WIN32)
128+
129+
SET(DOC_DESTINATION ".")
130+
IF(RPM_LAYOUT)
131+
SET(DOC_DESTINATION "share/doc/${CPACK_PACKAGE_NAME}-${MYSQLCPPCONN_VERSION}")
132+
ENDIF()
133+
134+
INSTALL(FILES
135+
${CPACK_RESOURCE_FILE_README}
136+
${CPACK_RESOURCE_FILE_INSTALL}
137+
${CPACK_RESOURCE_FILE_LICENSE}
138+
"${CMAKE_SOURCE_DIR}/ANNOUNCEMENT"
139+
DESTINATION ${DOC_DESTINATION} OPTIONAL COMPONENT Readme)
140+
141+
SET(COMMON_IGNORE_FILES
142+
"/CMakeFiles/"
143+
"/Testing/"
144+
"/.bzr/"
145+
"_CPack_Packages/"
146+
"~"
147+
".swp"
148+
".log"
149+
".gz"
150+
".directory$"
151+
"CMakeCache.txt"
152+
"Makefile"
153+
"install_manifest.txt"
154+
)
155+
SET(PRJ_COMMON_IGNORE_FILES
156+
${COMMON_IGNORE_FILES}
157+
"ANNOUNCEMENT_102_ALPHA"
158+
"ANNOUNCEMENT_103_ALPHA"
159+
"ANNOUNCEMENT_104_BETA"
160+
"ANNOUNCEMENT_105_GA"
161+
"ANNOUNCEMENT_110_GA"
162+
"ANNOUNCEMENT_111_GA"
163+
"ANNOUNCEMENT_DRAFT"
164+
)
165+
166+
SET(CPACK_SOURCE_IGNORE_FILES
167+
${PRJ_COMMON_IGNORE_FILES}
168+
"cppconn/config.h$"
169+
"cppconn/version_info.h$"
170+
"driver/nativeapi/binding_config.h$"
171+
"driver/version_info.h$"
172+
)
173+
SET(CPACK_PACKAGE_IGNORE_FILES ${PRJ_COMMON_IGNORE_FILES} "something_there" )
174+
SET(CPACK_SOURCE_GENERATOR "TGZ")
175+
176+
SET(MYSQLCPPCONN_GCOV_ENABLE 0 CACHE BOOL "gcov-enabled")
177+
IF(CMAKE_COMPILER_IS_GNUCC)
178+
ADD_DEFINITIONS("-Wall -fPIC -Woverloaded-virtual")
179+
IF (MYSQLCPPCONN_GCOV_ENABLE)
180+
ADD_DEFINITIONS("-fprofile-arcs -ftest-coverage")
181+
ENDIF (MYSQLCPPCONN_GCOV_ENABLE)
182+
ENDIF(CMAKE_COMPILER_IS_GNUCC)
183+
184+
# SET(CPACK_*) before the INCLUDE(CPack)
185+
INCLUDE(CPack)
186+
187+
IF(WIN32)
188+
STRING(REGEX REPLACE "MYSQLCPPCONN" "MySQL/ConnectorCPP" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
189+
ENDIF(WIN32)
190+
MESSAGE(STATUS "Installation path is: ${CMAKE_INSTALL_PREFIX} (overwrite with -DCMAKE_INSTALL_PREFIX=/your/path)")

VersionInfo.cmake.in

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,3 @@ SET(CONNECTOR_BASE_VERSION "${CONNECTOR_MAJOR}.${CONNECTOR_MINOR}")
5353
SET(CONNECTOR_BASE_PREVIOUS "1.0")
5454
SET(CONNECTOR_NUMERIC_VERSION "${CONNECTOR_BASE_VERSION}.${CONNECTOR_PATCH}")
5555
SET(CONNECTOR_VERSION "${CONNECTOR_NUMERIC_VERSION}${CONNECTOR_LEVEL}")
56-
57-
SET(CPACK_PACKAGE_VERSION_MAJOR ${CONNECTOR_MAJOR})
58-
SET(CPACK_PACKAGE_VERSION_MINOR ${CONNECTOR_MINOR})
59-
SET(CPACK_PACKAGE_VERSION_PATCH ${CONNECTOR_PATCH})
60-
SET(CPACK_PACKAGE_RELEASE_TYPE "")
61-
62-
# Needed for CPACK configuraiton, used for file name construction. Thus leaving it as is
63-
IF(EXTRA_VERSION)
64-
SET(MYSQLCPPCONN_VERSION "${CONNECTOR_NUMERIC_VERSION}${EXTRA_VERSION}${CPACK_PACKAGE_RELEASE_TYPE}")
65-
ELSE(EXTRA_VERSION)
66-
SET(MYSQLCPPCONN_VERSION "${CONNECTOR_NUMERIC_VERSION}${CPACK_PACKAGE_RELEASE_TYPE}")
67-
ENDIF(EXTRA_VERSION)
68-

cmake/DepFindBoost.cmake

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
2+
#
3+
# This program is free software; you can redistribute it and/or modify
4+
# it under the terms of the GNU General Public License, version 2.0, as
5+
# published by the Free Software Foundation.
6+
#
7+
# This program is also distributed with certain software (including
8+
# but not limited to OpenSSL) that is licensed under separate terms,
9+
# as designated in a particular file or component or in included license
10+
# documentation. The authors of MySQL hereby grant you an
11+
# additional permission to link the program and your derivative works
12+
# with the separately licensed software that they have included with
13+
# MySQL.
14+
#
15+
# Without limiting anything contained in the foregoing, this file,
16+
# which is part of MySQL Connector/C++, is also subject to the
17+
# Universal FOSS Exception, version 1.0, a copy of which can be found at
18+
# http://oss.oracle.com/licenses/universal-foss-exception.
19+
#
20+
# This program is distributed in the hope that it will be useful, but
21+
# WITHOUT ANY WARRANTY; without even the implied warranty of
22+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23+
# See the GNU General Public License, version 2.0, for more details.
24+
#
25+
# You should have received a copy of the GNU General Public License
26+
# along with this program; if not, write to the Free Software Foundation, Inc.,
27+
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28+
29+
##########################################################################
30+
#
31+
# Input:
32+
#
33+
# WITH_BOOST - location where to look for Boost. If not set,
34+
# system-wide locations are searched
35+
#
36+
# Output:
37+
#
38+
# BOOST_ROOT
39+
#
40+
# Boost::boost - library target to link against.
41+
#
42+
43+
add_config_option(WITH_BOOST PATH "Boost install location")
44+
45+
if(NOT DEFINED BOOST_ROOT)
46+
set(BOOST_ROOT ${WITH_BOOST})
47+
endif()
48+
49+
50+
# Do not use system paths if user provided location.
51+
52+
if(BOOST_ROOT)
53+
set(Boost_NO_SYSTEM_PATHS ON)
54+
endif()
55+
56+
set(Boost_NO_BOOST_CMAKE ON)
57+
set(Boost_USE_STATIC_LIBS TRUE CACHE BOOL "Link with static Boost libraries")
58+
59+
if(NOT TARGET Boost::boost)
60+
61+
# Note: FindBoost does not honor QUIET option
62+
find_package(Boost)
63+
64+
# Older FindBoost modules do not create this target
65+
66+
if(Boost_FOUND AND NOT TARGET Boost::boost)
67+
add_library(boost INTERFACE)
68+
target_include_directories(boost INTERFACE ${Boost_INCLUDE_DIRS})
69+
add_library(Boost::boost ALIAS boost)
70+
endif()
71+
72+
endif()
73+
74+
if(NOT TARGET Boost::boost)
75+
message(FATAL_ERROR "Boost was not found. You can set WITH_BOOST to point at Boost install location.")
76+
endif()
77+
78+
set(BOOST_ROOT "${Boost_INCLUDE_DIRS}" CACHE INTERNAL "")

0 commit comments

Comments
 (0)