|
| 1 | +# Copyright (c) 2020, 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 | +cmake_minimum_required(VERSION 3.0) |
| 30 | + |
| 31 | +# |
| 32 | +# This is test cmake project that uses Connector/C++ as a subproject, |
| 33 | +# to verify that this usage scenario works. |
| 34 | +# |
| 35 | + |
| 36 | +project(Sub_project_test C CXX) |
| 37 | + |
| 38 | +# |
| 39 | +# Find Connector/C++ sources. |
| 40 | +# |
| 41 | + |
| 42 | +if (NOT DEFINED CONCPP_SRC) |
| 43 | + get_filename_component(CONCPP_SRC ../.. REALPATH) |
| 44 | +endif() |
| 45 | + |
| 46 | +message("- using Con/C++ sources at: ${CONCPP_SRC}") |
| 47 | + |
| 48 | +if (NOT EXISTS ${CONCPP_SRC}/CMakeLists.txt) |
| 49 | + message(FATAL_ERROR |
| 50 | + "Could not find CMakeLists.txt at Con/C++ source location." |
| 51 | + ) |
| 52 | +endif() |
| 53 | + |
| 54 | +# |
| 55 | +# If CONCPP_CACHE is defined, it should point at Connector/C++ |
| 56 | +# build location where a cmake cache is stored. Various settings |
| 57 | +# required to build connector source are read from that cache. |
| 58 | +# |
| 59 | + |
| 60 | +if (DEFINED CONCPP_CACHE) |
| 61 | + |
| 62 | + message("- loading settings from Con/C++ cmake cache at: ${CONCPP_CACHE}") |
| 63 | + load_cache(${CONCPP_CACHE} READ_WITH_PREFIX "" |
| 64 | + WITH_SSL |
| 65 | + WITH_JDBC |
| 66 | + WITH_BOOST |
| 67 | + WITH_MYSQL MYSQL_INCLUDE_DIR MYSQL_LIB_DIR MYSQL_CONFIG_EXECUTABLE |
| 68 | + ) |
| 69 | + |
| 70 | + message("- WITH_SSL: ${WITH_SSL}") |
| 71 | + message("- WITH_BOOST: ${WITH_BOOST}") |
| 72 | + message("- WITH_MYSQL: ${WITH_MYSQL} (${MYSQL_INCLUDE_DIR} ${MYSQL_LIB_DIR})") |
| 73 | + |
| 74 | +endif() |
| 75 | + |
| 76 | +# |
| 77 | +# Include Connector/C++ as a sub-project |
| 78 | +# |
| 79 | + |
| 80 | +add_subdirectory(${CONCPP_SRC} connector-cpp) |
| 81 | + |
| 82 | +# |
| 83 | +# Define test applications to verify that they build correctly. |
| 84 | +# |
| 85 | + |
| 86 | +set(CMAKE_CXX_STANDARD 11) |
| 87 | + |
| 88 | +add_executable(devapi_test ${CONCPP_SRC}/testapp/devapi_test.cc) |
| 89 | +target_link_libraries(devapi_test connector) |
| 90 | + |
| 91 | +add_executable(xapi_test ${CONCPP_SRC}/testapp/xapi_test.c) |
| 92 | +target_link_libraries(xapi_test connector) |
| 93 | + |
| 94 | +if (WITH_JDBC) |
| 95 | + |
| 96 | + add_executable(jdbc_test ${CONCPP_SRC}/testapp/jdbc_test.cc) |
| 97 | + target_link_libraries(jdbc_test connector-jdbc) |
| 98 | + |
| 99 | +endif() |
0 commit comments