1
- # Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
1
+ # Copyright (c) 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.
2
6
#
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
- # Try find out information about the build environment that
30
- # might be useful to the user of the C/C++ libraries
31
-
32
-
33
- set (buildinfo_in "${PROJECT_SOURCE_DIR} /BUILDINFO.in" )
34
- set (buildinfo_out "${PROJECT_BINARY_DIR} /BUILDINFO.txt" )
35
-
36
- configure_file (
37
- "${PROJECT_SOURCE_DIR} /BUILDINFO.in"
38
- "${PROJECT_BINARY_DIR} /BUILDINFO.txt"
39
- @ONLY
40
- )
41
-
42
- # TODO: OpenSSL information
43
-
44
- if (WIN32 )
45
-
46
- if (STATIC_MSVCRT)
47
- file (APPEND ${buildinfo_out}
48
- "MSVC runtime : linked statically (/MT)\n "
49
- )
50
- else ()
51
- file (APPEND ${buildinfo_out}
52
- "MSVC runtime : linked dynamically (/MD)\n "
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/ODBC, 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
+ FUNCTION (GENERATE_INFO_BIN)
32
+
33
+ IF (DEFINED ENV{PRODUCT_ID} AND $ENV{PRODUCT_ID} MATCHES "source-dist" )
34
+ MESSAGE ("Generating INFO_BIN is skipped for the source package" )
35
+ RETURN ()
36
+ ENDIF ()
37
+
38
+ MESSAGE ("Generating INFO_BIN" )
39
+ string (TIMESTAMP INFO_DATE "%Y-%m-%d" )
40
+
41
+ IF (CMAKE_BUILD_TYPE )
42
+ SET (INFO_BUILD_TYPE "build-type : ${CMAKE_BUILD_TYPE} \n " )
43
+ ENDIF ()
44
+
45
+ IF (OPENSSL_VERSION_GLOBAL)
46
+ SET (INFO_SSL "ssl-library : OpenSSL ${OPENSSL_VERSION_GLOBAL} \n " )
47
+ ELSE ()
48
+ SET (INFO_SSL "ssl-library : WolfSSL ${WOLFSSL_VERSION_GLOBAL} \n " )
49
+ ENDIF ()
50
+
51
+ IF (CMAKE_OSX_DEPLOYMENT_TARGET)
52
+ SET (INFO_MACOS_TARGET "macos-target : ${CMAKE_OSX_DEPLOYMENT_TARGET} \n " )
53
+ ENDIF ()
54
+
55
+ IF (APPLE )
56
+ execute_process (
57
+ COMMAND sw_vers -productVersion
58
+ ERROR_QUIET
59
+ OUTPUT_VARIABLE _prod_version
60
+ RESULT_VARIABLE _result_code1
61
+ OUTPUT_STRIP_TRAILING_WHITESPACE
53
62
)
54
- endif ()
55
63
56
- elseif (APPLE )
57
-
58
- set (_macos_ver "MacOS version :" )
59
-
60
- execute_process (
61
- COMMAND sw_vers -productVersion
62
- ERROR_QUIET
63
- OUTPUT_VARIABLE _prod_version
64
- RESULT_VARIABLE _result_code1
65
- OUTPUT_STRIP_TRAILING_WHITESPACE
66
- )
67
-
68
- if (NOT _result_code1)
69
-
70
- set (_macos_ver "${_macos_ver} ${_prod_version} " )
64
+ IF (_prod_version)
65
+ SET (INFO_MACOS_VERSION "macos-version : ${_prod_version} \n " )
66
+ ENDIF ()
71
67
72
68
execute_process (
73
69
COMMAND sw_vers -buildVersion
@@ -77,39 +73,102 @@ elseif(APPLE)
77
73
OUTPUT_STRIP_TRAILING_WHITESPACE
78
74
)
79
75
80
- if (NOT _result_code2)
81
- set (_macos_ver "${_macos_ver} (${_build_version} )" )
82
- endif ()
83
-
84
- file (APPEND ${buildinfo_out} "${_macos_ver} \n " )
85
-
86
- endif ()
87
-
88
- else ()
89
-
90
- execute_process (
91
- COMMAND ldd --version
92
- COMMAND head -1
93
- ERROR_QUIET
94
- OUTPUT_VARIABLE _glibc_version
95
- RESULT_VARIABLE _result_code
96
- )
97
-
98
- if (_result_code STREQUAL "0" )
99
- string (REGEX REPLACE "ldd *" "" _glibc_version "${_glibc_version} " )
100
- file (APPEND ${buildinfo_out}
101
- "GLIBC version : ${_glibc_version} \n "
102
- )
103
- endif ()
104
-
105
- endif ()
106
-
107
- if (WITH_JDBC)
108
- file (APPEND ${buildinfo_out} "\n Legacy connector information:\n\n "
109
- "MySQL version : ${MYSQL_VERSION} \n "
110
- )
111
- # TODO: Boost version
112
- endif ()
113
-
114
-
115
- install (FILES "${PROJECT_BINARY_DIR} /BUILDINFO.txt" DESTINATION . COMPONENT Readme)
76
+ IF (_build_version)
77
+ SET (INFO_MACOS_BUILD "macos-build : ${_build_version} \n " )
78
+ ENDIF ()
79
+ ENDIF ()
80
+
81
+ IF (WITH_JDBC)
82
+ IF (Boost_VERSION)
83
+ SET (INFO_BOOST "boost-version : ${Boost_MAJOR_VERSION} .${Boost_MINOR_VERSION} .${Boost_SUBMINOR_VERSION} \n " )
84
+ ENDIF ()
85
+
86
+ SET (INFO_MACOS_BUILD "mysql-version : ${MYSQL_VERSION} \n " )
87
+ ENDIF ()
88
+
89
+ CONFIGURE_FILE (INFO_BIN.in "${CMAKE_SOURCE_DIR} /INFO_BIN" )
90
+ install (FILES "${CMAKE_SOURCE_DIR} /INFO_BIN" DESTINATION . COMPONENT Readme)
91
+ ENDFUNCTION ()
92
+
93
+ include (version .cmake)
94
+
95
+ FUNCTION (GENERATE_INFO_SRC)
96
+ MESSAGE ("Generating INFO_SRC" )
97
+
98
+ IF (NOT EXISTS INFO_SRC)
99
+ SET (INFO_VERSION "${CONCPP_PACKAGE_VERSION} " )
100
+
101
+ find_program (GIT_FOUND NAMES git)
102
+
103
+ IF (GIT_FOUND AND IS_DIRECTORY "${PROJECT_SOURCE_DIR} /.git" )
104
+ execute_process (
105
+ COMMAND git symbolic -ref --short HEAD
106
+ ERROR_QUIET
107
+ OUTPUT_VARIABLE GIT_BRANCH_NAME
108
+ RESULT_VARIABLE _result_code3
109
+ OUTPUT_STRIP_TRAILING_WHITESPACE
110
+ )
111
+
112
+ IF (GIT_BRANCH_NAME)
113
+ execute_process (
114
+ COMMAND git log -1 --format=%cd --date=short
115
+ ERROR_QUIET
116
+ OUTPUT_VARIABLE GIT_DATE
117
+ RESULT_VARIABLE _result_code4
118
+ OUTPUT_STRIP_TRAILING_WHITESPACE
119
+ )
120
+
121
+ IF (GIT_DATE)
122
+ SET (INFO_DATE "date : ${GIT_DATE} \n " )
123
+ ENDIF ()
124
+
125
+ IF (GIT_BRANCH_NAME)
126
+ SET (INFO_BRANCH "branch : ${GIT_BRANCH_NAME} \n " )
127
+ ENDIF ()
128
+
129
+
130
+ execute_process (
131
+ COMMAND git rev-parse HEAD
132
+ ERROR_QUIET
133
+ OUTPUT_VARIABLE GIT_COMMIT
134
+ RESULT_VARIABLE _result_code5
135
+ OUTPUT_STRIP_TRAILING_WHITESPACE
136
+ )
137
+
138
+ IF (GIT_COMMIT)
139
+ SET (INFO_COMMIT "commit : ${GIT_COMMIT} \n " )
140
+ ENDIF ()
141
+
142
+ execute_process (
143
+ COMMAND git rev-parse --short HEAD
144
+ ERROR_QUIET
145
+ OUTPUT_VARIABLE GIT_SHORT
146
+ RESULT_VARIABLE _result_code6
147
+ OUTPUT_STRIP_TRAILING_WHITESPACE
148
+ )
149
+
150
+ IF (GIT_SHORT)
151
+ SET (INFO_SHORT "short : ${GIT_SHORT} \n " )
152
+ ENDIF ()
153
+ ENDIF ()
154
+ ELSE ()
155
+ # git local repository does not exist, but the env variables might be set
156
+ IF (DEFINED ENV{PUSH_REVISION})
157
+ SET (INFO_COMMIT "commit : $ENV{PUSH_REVISION} \n " )
158
+ STRING (SUBSTRING $ENV{PUSH_REVISION} 0 8 GIT_SHORT)
159
+ SET (INFO_SHORT "short : ${GIT_SHORT} \n " )
160
+ ENDIF ()
161
+
162
+ IF (DEFINED ENV{BRANCH_SOURCE})
163
+ STRING (REGEX MATCH " [^ ]+" GIT_BRANCH_NAME $ENV{BRANCH_SOURCE} )
164
+ SET (INFO_BRANCH "branch : ${GIT_BRANCH_NAME} \n " )
165
+ ENDIF ()
166
+ ENDIF ()
167
+
168
+ CONFIGURE_FILE (INFO_SRC.in "${CMAKE_SOURCE_DIR} /INFO_SRC" )
169
+ ENDIF ()
170
+ install (FILES "${CMAKE_SOURCE_DIR} /INFO_SRC" DESTINATION . COMPONENT Readme)
171
+ ENDFUNCTION ()
172
+
173
+ GENERATE_INFO_SRC()
174
+ GENERATE_INFO_BIN()
0 commit comments