Debian Codegraph @

unittest/gunit/components/mysql_server/CMakeLists.txt

raw
1 # Copyright (c) 2016, 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 INCLUDE_DIRECTORIES(
25 ${CMAKE_SOURCE_DIR}/components/example
26 )
27
28 REMOVE_DEFINITIONS(-DMYSQL_SERVER)
29
30 # Add tests
31 SET(TESTS registry dynamic_loader)
32
33 ADD_LIBRARY(unit_test_common STATIC
34 unit_test_common.cc )
35
36 FOREACH(test ${TESTS})
37 MYSQL_ADD_EXECUTABLE(${test}-t
38 ${test}-t.cc
39 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugin_output_directory
40 ADD_TEST ${test}
41 ENABLE_EXPORTS
42 LINK_LIBRARIES ${GTEST_LIBRARIES} mysys minchassis unit_test_common
43 )
44 ENDFOREACH()
45
46 MYSQL_ADD_EXECUTABLE(minimal_chassis-t
47 minimal_chassis-t.cc
48 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugin_output_directory
49 ADD_TEST minimal_chassis-t
50 ENABLE_EXPORTS
51 LINK_LIBRARIES ${GTEST_LIBRARIES} mysys minchassis unit_test_common
52 DEPENDENCIES component_example_component1
53 )
54
55 MYSQL_ADD_EXECUTABLE(minimal_chassis_test_driver-t
56 minimal_chassis_test_driver-t.cc
57 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugin_output_directory
58 ADD_TEST minimal_chassis_test_driver-t
59 ENABLE_EXPORTS
60 LINK_LIBRARIES ${GTEST_LIBRARIES} server_unittest_library unit_test_common
61 DEPENDENCIES component_example_component1
62 )
63
64 IF(WIN32)
65 TARGET_LINK_LIBRARIES(minimal_chassis_test_driver-t my_nt_servc)
66 ENDIF()
67
68 IF(NOT WITH_SHARED_UNITTEST_LIBRARY)
69 TARGET_LINK_LIBRARIES(minimal_chassis_test_driver-t
70 mysql_server_component_services)
71 ENDIF()
72
73 IF(WIN32)
74 ADD_DEPENDENCIES(minimal_chassis_test_driver-t ext::libprotobuf-lite)
75 # Copy dlls for libprotobuf-lite and libcrypto/libssl to plugin dir.
76 FUNCTION(COPY_DLL_FOR_UNITTEST DLL_FILE_NAME)
77 SET(run_dir "${CMAKE_BINARY_DIR}/runtime_output_directory/")
78 SET(plg_dir "${CMAKE_BINARY_DIR}/plugin_output_directory/")
79 ADD_CUSTOM_COMMAND(TARGET minimal_chassis_test_driver-t POST_BUILD
80 COMMAND ${CMAKE_COMMAND} -E copy_if_different
81 "${run_dir}/${CMAKE_CFG_INTDIR}/${DLL_FILE_NAME}"
82 "${plg_dir}/${CMAKE_CFG_INTDIR}/${DLL_FILE_NAME}"
83 COMMENT "Copying ${DLL_FILE_NAME}"
84 )
85 ENDFUNCTION()
86 GET_FILENAME_COMPONENT(CRYPTO_NAME "${HAVE_CRYPTO_DLL}" NAME)
87 GET_FILENAME_COMPONENT(OPENSSL_NAME "${HAVE_OPENSSL_DLL}" NAME)
88
89 IF(NOT WIN32_CLANG)
90 COPY_DLL_FOR_UNITTEST("$<TARGET_FILE_NAME:abseil_dll>")
91 COPY_DLL_FOR_UNITTEST("$<TARGET_FILE_NAME:libprotobuf-lite>")
92 ENDIF()
93 COPY_DLL_FOR_UNITTEST("${CRYPTO_NAME}")
94 COPY_DLL_FOR_UNITTEST("${OPENSSL_NAME}")
95 ENDIF()
96
97 MYSQL_ADD_EXECUTABLE(reference_cache-t
98 reference_cache-t.cc
99 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/plugin_output_directory
100 ADD_TEST reference_cache-t
101 ENABLE_EXPORTS
102 LINK_LIBRARIES ${GTEST_LIBRARIES} server_unittest_library unit_test_common
103 DEPENDENCIES component_reference_cache component_test_reference_cache
104 )
105
106 IF(WIN32)
107 TARGET_LINK_LIBRARIES(reference_cache-t my_nt_servc)
108 ENDIF()
109 IF(NOT WITH_SHARED_UNITTEST_LIBRARY)
110 TARGET_LINK_LIBRARIES(reference_cache-t mysql_server_component_services)
111 ENDIF()
112
113 MYSQL_ADD_COMPONENT(self_required_test_component
114 self_required_test_component.cc
115 MODULE_ONLY
116 SKIP_INSTALL
117 )
118 MYSQL_ADD_COMPONENT(cyclic_dependency_test_component_1
119 cyclic_dependency_test_component_1.cc
120 MODULE_ONLY
121 SKIP_INSTALL
122 )
123 MYSQL_ADD_COMPONENT(cyclic_dependency_test_component_2
124 cyclic_dependency_test_component_2.cc
125 MODULE_ONLY
126 SKIP_INSTALL
127 )
128 MYSQL_ADD_COMPONENT(test_reference_cache
129 test_reference_cache.cc
130 MODULE_ONLY
131 SKIP_INSTALL
132 )
133
134 SET(EXAMPLE_COMPONENTS
135 component_example_component1
136 component_example_component2
137 component_example_component3
138 component_self_required_test_component
139 component_cyclic_dependency_test_component_1
140 component_cyclic_dependency_test_component_2
141 )
142
143 FOREACH(EXAMPLE_COMPONENT ${EXAMPLE_COMPONENTS})
144 ADD_DEPENDENCIES(dynamic_loader-t ${EXAMPLE_COMPONENT})
145 ENDFOREACH()