Debian Codegraph @

unittest/gunit/xplugin/xpl/CMakeLists.txt

raw
1 # Copyright (c) 2020, 2026, Oracle and/or its affiliates.
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,
5 # as published by the Free Software Foundation.
6 #
7 # This program is designed to work 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 additional
11 # permission to link the program and your derivative works with the
12 # separately licensed software that they have either included with
13 # the program or referenced in the documentation.
14 #
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License, version 2.0, for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write to the Free Software
22 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24
25 GET_DIRECTORY_PROPERTY(MYSQLX_CLIENT_LIB
26 DIRECTORY ${MYSQLX_PROJECT_DIR}
27 DEFINITION MYSQLX_CLIENT_LIB
28 )
29
30 SET(XPL_UNIT_TESTS xplugin_unit_tests)
31
32 INCLUDE(source_files.cmake)
33
34 # There may be extra semicolons in code generated by protobuf.
35 MY_CHECK_CXX_COMPILER_WARNING("-Wextra-semi" HAS_WARN_FLAG)
36 IF(HAS_WARN_FLAG)
37 STRING_APPEND(CMAKE_CXX_FLAGS " ${HAS_WARN_FLAG}")
38 ENDIF()
39
40 IF(MYSQLX_ADDITIONAL_TESTS_ENABLE)
41 INCLUDE(mysql_function_names.cmake)
42 LIST(APPEND XPL_TEST_SRC "${MYSQLX_GENERATE_DIR}/mysql_function_names_t.cc")
43 ENDIF()
44
45 # Fixes "C1128: number of sections exceeded object file format limit" in MSVC
46 IF(MSVC)
47 ADD_COMPILE_FLAGS(
48 mock/mock.cc
49 COMPILE_FLAGS "/bigobj"
50 )
51 ENDIF()
52
53 ADD_STATIC_LIBRARY(xpl_test_src ${XPL_TEST_SRC}
54 DEPENDENCIES mysqlx
55 LINK_LIBRARIES ext::zlib ext::lz4 ext::zstd extra::rapidjson ext::icu)
56
57 IF(WITH_PROTOBUF STREQUAL "bundled")
58 TARGET_INCLUDE_DIRECTORIES(xpl_test_src SYSTEM BEFORE PUBLIC
59 "${BUNDLED_ABSEIL_SRCDIR}")
60 ENDIF()
61
62 MYSQL_ADD_EXECUTABLE(${XPL_UNIT_TESTS}
63 ../test_main.cc
64 LINK_LIBRARIES xpl_test_src
65 ADD_TEST xplugin
66 )
67 SET_TESTS_PROPERTIES(xplugin PROPERTIES TIMEOUT 180)
68
69 ADD_COMPILE_FLAGS(${XPL_TEST_SRC}
70 COMPILE_FLAGS "${MYSQLX_PROTOCOL_FLAGS}"
71 )
72
73 ADD_DEPENDENCIES(${XPL_UNIT_TESTS}
74 mysqlx
75 )
76
77 # New warning in Visual Studio 2008
78 # '%$S': virtual function overrides '%$pS', previous versions of the compiler
79 # did not override when parameters only differed by const/volatile qualifiers
80 IF(WIN32)
81 SET_TARGET_PROPERTIES(${XPL_UNIT_TESTS} PROPERTIES COMPILE_FLAGS "/wd4373")
82 ENDIF(WIN32)
83
84 TARGET_LINK_LIBRARIES(${XPL_UNIT_TESTS}
85 ${GCOV_LDFLAGS}
86 ${MYSQLX_CLIENT_LIB}
87 mysqlx
88 mysqlclient
89 gtest
90 gmock
91 )
92