Skip to content

Commit 4e382f5

Browse files
committed
cmake: Move PackageSpecs.cmake to packaging/
Also removing some top-level files that seem no longer needed
1 parent 5cf5e0b commit 4e382f5

File tree

13 files changed

+179
-217
lines changed

13 files changed

+179
-217
lines changed

CMakeLists.txt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ else()
105105
endif()
106106

107107

108-
#
109-
# Connector System Configuration
110-
#
111-
include(config.cmake)
112-
113-
114108
#
115109
# Install settings
116110
# ================
@@ -695,9 +689,7 @@ message("Connector libraries will be installed at: ${INSTALL_LIB_DIR}")
695689
option(WITH_PACKAGES "Configure for building binary/source packages" OFF)
696690

697691
if(WITH_PACKAGES)
698-
include(PackageSpecs.cmake)
699692
ADD_SUBDIRECTORY(packaging)
700-
ADD_SUBDIRECTORY(packaging/WiX)
701693
endif()
702694

703695

CTestConfig.cmake

Lines changed: 0 additions & 44 deletions
This file was deleted.

common/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,31 @@ add_library(common STATIC
3535

3636
target_link_libraries(common cdk uuid_gen)
3737

38+
#
39+
# Generate version info
40+
#
41+
42+
set(CLIENT_VERSION ${CONCPP_VERSION})
43+
44+
if(EXTRA_NAME_SUFFIX STREQUAL "-commercial")
45+
SET(CONCPP_LICENSE "COMMERCIAL")
46+
else()
47+
SET(CONCPP_LICENSE "GPL-2.0")
48+
endif()
49+
50+
#
51+
# Note: generated version_info.h is placed in the build location
52+
# and the common target is configured to include it before the
53+
# original version in the sources
54+
#
55+
56+
configure_file(version_info.h version_info.h @ONLY)
57+
58+
# FIXME: This include path is made public, because other components
59+
# such as devapi use private headers of the common component.
60+
61+
target_include_directories(common
62+
BEFORE PUBLIC ${CMAKE_CURRENT_BINARY_DIR}
63+
)
64+
3865
add_subdirectory(tests)

common/common.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,38 @@
1+
/*
2+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License, version 2.0, as
6+
* published by the Free Software Foundation.
7+
*
8+
* This program is also distributed with certain software (including
9+
* but not limited to OpenSSL) that is licensed under separate terms,
10+
* as designated in a particular file or component or in included license
11+
* documentation. The authors of MySQL hereby grant you an
12+
* additional permission to link the program and your derivative works
13+
* with the separately licensed software that they have included with
14+
* MySQL.
15+
*
16+
* Without limiting anything contained in the foregoing, this file,
17+
* which is part of MySQL Connector/C++, is also subject to the
18+
* Universal FOSS Exception, version 1.0, a copy of which can be found at
19+
* http://oss.oracle.com/licenses/universal-foss-exception.
20+
*
21+
* This program is distributed in the hope that it will be useful, but
22+
* WITHOUT ANY WARRANTY; without even the implied warranty of
23+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
24+
* See the GNU General Public License, version 2.0, for more details.
25+
*
26+
* You should have received a copy of the GNU General Public License
27+
* along with this program; if not, write to the Free Software Foundation, Inc.,
28+
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29+
*/
30+
131
#ifndef MYSQLX_COMMON_COMMON_H
232
#define MYSQLX_COMMON_COMMON_H
333

434
#include <mysqlx/common.h>
35+
#include <version_info.h>
536

637

738
namespace mysqlx {

common/session.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ POP_SYS_WARNINGS
4242
#include "settings.h"
4343
#include "session.h"
4444
#include "result.h"
45-
#include "config.h"
4645

4746
#ifndef _WIN32
4847
#include <sys/types.h>
@@ -192,10 +191,9 @@ void mysqlx::common::Settings_impl::Data::init_connection_attr()
192191
m_connection_attr["_platform"] = platform;
193192
m_connection_attr["_source_host"] =
194193
cdk::foundation::connection::get_local_hostname();
195-
m_connection_attr["_client_name"] = PACKAGE_NAME;
196-
m_connection_attr["_client_version"] = PACKAGE_VERSION;
197-
m_connection_attr["_client_license"] = PACKAGE_LICENSE;
198-
194+
m_connection_attr["_client_name"] = CONCPP_NAME;
195+
m_connection_attr["_client_version"] = CONCPP_VERSION;
196+
m_connection_attr["_client_license"] = CONCPP_LICENSE;
199197
}
200198

201199
void mysqlx::common::Settings_impl::Data::clear_connection_attr()
Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved.
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License, version 2.0, as
@@ -28,44 +28,23 @@
2828
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2929
*/
3030

31-
#ifndef MYSQLX_GLOBAL_H
32-
#define MYSQLX_GLOBAL_H
31+
#ifndef MYSQLX_COMMON_VERSION_INFO
32+
#define MYSQLX_COMMON_VERSION_INFO
3333

3434
/*
35-
This header contains global declarations that are used by both DevAPI
36-
and XAPI. This is only implementation-side stuff - No public header
37-
should depend on this one.
35+
Version information which is used for example for default
36+
connection attributes.
37+
38+
When build system is configured by cmake, a new file is generated
39+
from this one with version and license values substituted by
40+
cmake and build system is configured so that the generated
41+
header takes precedence over this one. But code can be built even
42+
if header with real values was not generated - in that case the
43+
values specified here will be used.
3844
*/
3945

40-
#include "cdk/extra/uuid/include/uuid_gen.h"
41-
42-
namespace mysqlx {
43-
44-
/*
45-
Wrapper around uuid generator which ensures that it is properly
46-
initialized using process id (so that concurrent processes use
47-
different UUIDs).
48-
*/
49-
50-
inline
51-
void generate_uuid(uuid::uuid_type &buf)
52-
{
53-
/*
54-
Note: This static initializer instance will be constructed
55-
only once.
56-
*/
57-
static struct Initializer
58-
{
59-
Initializer()
60-
{
61-
uuid::set_seed_from_time_pid();
62-
}
63-
}
64-
uuid_init;
65-
66-
uuid::generate_uuid(buf);
67-
}
68-
69-
}
46+
#define CONCPP_NAME "mysql-connector-cpp"
47+
#define CONCPP_VERSION "@CONCPP_VERSION@"
48+
#define CONCPP_LICENSE "@CONCPP_LICENSE@"
7049

7150
#endif

config.h.in

Lines changed: 0 additions & 28 deletions
This file was deleted.

devapi/impl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
#include <mysql/cdk/converters.h>
4242
#include <expr_parser.h>
4343

44-
#include "../global.h"
4544
#include "../common/result.h"
4645
#include "../common/op_impl.h"
4746

packaging/CMakeLists.txt

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,89 @@
2727
# along with this program; if not, write to the Free Software Foundation, Inc.,
2828
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2929

30+
31+
# ======================================================================
32+
# Licenses for binary packages
33+
# ======================================================================
34+
35+
if(EXISTS "${CMAKE_SOURCE_DIR}/LICENSE.mysql.txt")
36+
set(LIC_FILE "LICENSE.mysql") # Without ".txt" extension
37+
else()
38+
set(LIC_FILE "LICENSE") # Without ".txt" extension
39+
endif()
40+
41+
if(WIN32)
42+
set(info_ext ".txt")
43+
set(newline WIN32)
44+
else()
45+
set(info_ext "")
46+
set(newline UNIX)
47+
endif()
48+
49+
set(info_files README ${LIC_FILE})
50+
51+
foreach(file ${info_files})
52+
53+
set(file_src "${CMAKE_SOURCE_DIR}/${file}.txt")
54+
set(file_bin "${CMAKE_BINARY_DIR}/${file}${info_ext}")
55+
56+
configure_file("${file_src}" "${file_bin}" NEWLINE_STYLE ${newline})
57+
install(FILES "${file_bin}" DESTINATION ${INSTALL_DOC_DIR} COMPONENT Readme)
58+
59+
endforeach()
60+
61+
set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README${info_ext}")
62+
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/${LIC_FILE}${info_ext}")
63+
#set(CPACK_RESOURCE_FILE_INSTALL "...") # FIXME
64+
65+
66+
# ======================================================================
67+
# Package specifications
68+
# ======================================================================
69+
70+
if(APPLE AND NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")
71+
message(FATAL_ERROR "To create packages for OSX, build with clang compiler.")
72+
endif()
73+
74+
75+
include(PackageSpecs.cmake)
76+
3077
CONFIGURE_FILE(mysql-connector-c++.spec.in ${CMAKE_CURRENT_BINARY_DIR}/mysql-connector-c++.spec @ONLY)
3178
ADD_SUBDIRECTORY(deb-in)
79+
80+
81+
# ======================================================================
82+
# Custom target to build packages.
83+
# ======================================================================
84+
#
85+
# Note: target build_packages builds TGZ/ZIP packages using cpack.
86+
# Other package types are built outside of cmake/cpack, cmake is only
87+
# used to prepare information necessary to build them.
88+
#
89+
# Note: For information on building MSI packages look at WiX/CMakeLists.txt
90+
#
91+
92+
93+
add_custom_target(build_packages
94+
COMMAND cpack --config CPackConfig.cmake --verbose -C $<CONFIGURATION>
95+
COMMAND cpack --config CPackSourceConfig.cmake
96+
DEPENDS clean_source_tree
97+
)
98+
99+
add_custom_target(clean_source_tree
100+
COMMAND git clean -x -d -f
101+
COMMAND git submodule foreach --recursive git clean -x -d -f
102+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
103+
COMMENT "Cleaning source tree"
104+
)
105+
106+
set_property(TARGET clean_source_tree build_packages
107+
PROPERTY EXCLUDE_FROM_ALL 1
108+
)
109+
110+
set_property(TARGET clean_source_tree build_packages
111+
PROPERTY EXCLUDE_FROM_DEFAULT_BUILD 1
112+
)
113+
114+
115+
include(CPack)

0 commit comments

Comments
 (0)