Skip to content

Commit 3846551

Browse files
committed
cdk: cmake infrastructure for building external cmake projects
For exteranl dependencies, such as protobuf and compression libraries, their bundled sources are built as a separate, external cmake project and import targets are defined to refer to the produced libraries in the main project. New cmake commands add_ext() and add_ext_targets() are defined to manage this setup. Also, a mechanism to cache intial cmake settings and this way speed-up configuration of external projects is implemented.
1 parent 18d6c1d commit 3846551

File tree

619 files changed

+738
-257
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

619 files changed

+738
-257
lines changed

CMakeLists.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2828

2929

30-
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
30+
CMAKE_MINIMUM_REQUIRED(VERSION 3.1)
3131

3232
CMAKE_POLICY(VERSION 3.1)
3333
cmake_policy(SET CMP0022 NEW)
@@ -60,16 +60,23 @@ set(CMAKE_INSTALL_PREFIX "" CACHE PATH "Install location")
6060
#
6161
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
6262

63+
include(cdk/cmake/setup.cmake)
64+
include(cmake/setup.cmake)
65+
include(bootstrap)
66+
67+
# Note: Does not work well with Ninja -- not sure why
68+
69+
if(NOT CMAKE_GENERATOR MATCHES "Ninja")
70+
bootstrap()
71+
endif()
72+
6373

6474
##########################################################################
6575

6676
PROJECT(MySQL_CONCPP)
6777

6878
# Load cmake modules
6979

70-
include(cdk/cmake/setup.cmake)
71-
include(cmake/setup.cmake)
72-
7380
include(platform)
7481
include(dependency) # find_dependency()
7582
include(config_options) # add_config_option()

cdk/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ add_config(CDK_BIG_ENDIAN ${BIG_ENDIAN})
9494
#
9595

9696
find_dependency(SSL)
97-
find_dependency(Protobuf)
97+
#find_dependency(Protobuf)
9898
find_dependency(RapidJSON)
9999
find_dependency(Coverage)
100100

cdk/cmake/DepFindCompression.cmake

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Copyright (c) 2021, 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+
# Targets:
32+
#
33+
# (re)build-{zlib,lz4,zstd}
34+
#
35+
# Imported/alias targets:
36+
#
37+
# ext::zlib
38+
# ext::lz4
39+
# ext::zstd
40+
#
41+
# TODO:
42+
# - allow use of external, dynamic libraries instead of static linking
43+
#
44+
45+
if(TARGET ext::zlib)
46+
return()
47+
endif()
48+
49+
message(STATUS "Setting up compression libraries.")
50+
51+
# Use external builds from the bundled sources
52+
53+
add_ext(zlib)
54+
add_ext_targets(zlib zlib ext_zlib)
55+
56+
add_ext(lz4)
57+
add_ext_targets(lz4 lz4 ext_lz4)
58+
59+
add_ext(zstd)
60+
add_ext_targets(zstd zstd ext_zstd)

0 commit comments

Comments
 (0)