|
| 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. |
| 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" |
| 53 | + ) |
| 54 | + endif() |
| 55 | + |
| 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}") |
| 71 | + |
| 72 | + execute_process( |
| 73 | + COMMAND sw_vers -buildVersion |
| 74 | + ERROR_QUIET |
| 75 | + OUTPUT_VARIABLE _build_version |
| 76 | + RESULT_VARIABLE _result_code2 |
| 77 | + OUTPUT_STRIP_TRAILING_WHITESPACE |
| 78 | + ) |
| 79 | + |
| 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} "\nLegacy 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 .) |
0 commit comments