1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- cmake_minimum_required (VERSION 3.13 )
15+ cmake_minimum_required (VERSION 3.22 )
1616
1717project (cppdap VERSION 1.65.0 LANGUAGES CXX C )
1818
@@ -298,21 +298,19 @@ if(CPPDAP_BUILD_TESTS)
298298 if (CPPDAP_USE_EXTERNAL_GTEST_PACKAGE)
299299 find_package (GTest REQUIRED )
300300 else ()
301- list (APPEND DAP_TEST_LIST
302- ${CPPDAP_GOOGLETEST_DIR} /googletest/src/gtest-all.cc
303- )
304-
305- set (DAP_TEST_INCLUDE_DIR
306- ${CPPDAP_GOOGLETEST_DIR} /googlemock/include/
307- ${CPPDAP_GOOGLETEST_DIR} /googletest/
308- ${CPPDAP_GOOGLETEST_DIR} /googletest/include/
309- )
301+ set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
302+ set (INSTALL_GTEST OFF CACHE BOOL "" FORCE )
303+ add_subdirectory (${CPPDAP_GOOGLETEST_DIR} )
304+ # googletest has -Werror=maybe-uninitialized problems.
305+ # Disable all warnings in googletest code.
306+ target_compile_options (gtest PRIVATE -w )
307+ # gmock has -Werror=deprecated-copy problems.
308+ target_compile_options (gmock PRIVATE -w )
310309 endif ()
311310
312311 add_executable (cppdap-unittests ${DAP_TEST_LIST} )
313312 add_test (NAME cppdap-unittests COMMAND cppdap-unittests )
314313
315- target_include_directories (cppdap-unittests PUBLIC ${DAP_TEST_INCLUDE_DIR} )
316314 set_target_properties (cppdap-unittests PROPERTIES
317315 FOLDER "Tests"
318316 )
@@ -326,7 +324,7 @@ if(CPPDAP_BUILD_TESTS)
326324 if (CPPDAP_USE_EXTERNAL_GTEST_PACKAGE)
327325 target_link_libraries (cppdap-unittests PRIVATE cppdap GTest::gtest )
328326 else ()
329- target_link_libraries (cppdap-unittests PRIVATE cppdap )
327+ target_link_libraries (cppdap-unittests PRIVATE cppdap gtest gmock )
330328 endif ()
331329endif (CPPDAP_BUILD_TESTS )
332330
0 commit comments