Skip to content

Commit

Permalink
update googletest
Browse files Browse the repository at this point in the history
  • Loading branch information
phlptp committed Oct 1, 2024
1 parent 2b8ded3 commit 400b016
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 10 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright (c) 2019-2023,
# Copyright (c) 2019-2024,
# Lawrence Livermore National Security, LLC;
# See the top-level NOTICE for additional details. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
1 change: 1 addition & 0 deletions ThirdParty/googletest
Submodule googletest added at c9ccac
51 changes: 44 additions & 7 deletions config/AddGoogletest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
# Add make check, as well, which gives output on failed tests without having to set an environment
# variable.
#

include(extraMacros)
set(CMAKE_WARN_DEPRECATED OFF CACHE INTERNAL "" FORCE)
set(gtest_force_shared_crt ON CACHE INTERNAL "")

set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "")
Expand All @@ -31,15 +32,41 @@ if(NOT MSVC)
endif()

if(GOOGLE_TEST_INDIVIDUAL)
include(GoogleTest)
if(NOT CMAKE_VERSION VERSION_LESS 3.9)
include(GoogleTest)
else()
set(GOOGLE_TEST_INDIVIDUAL OFF)
endif()
endif()

function(add_unit_test test_source_file)
get_filename_component(test_name "${test_source_file}" NAME_WE)
add_executable("${test_name}" "${test_source_file}")
target_link_libraries("${test_name}" gtest gmock gtest_main)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
set_target_properties(${test_name} PROPERTIES FOLDER "Tests")
endfunction()

# Target must already exist
macro(add_gtest TESTNAME)
target_link_libraries(${TESTNAME} PUBLIC gtest gmock gtest_main)

if(GOOGLE_TEST_INDIVIDUAL)
gtest_discover_tests(${TESTNAME} TEST_PREFIX "${TESTNAME}." PROPERTIES FOLDER "Tests")
if(CMAKE_VERSION VERSION_LESS 3.10)
gtest_add_tests(
TARGET ${TESTNAME}
TEST_PREFIX "${TESTNAME}."
TEST_LIST TmpTestList
)
set_tests_properties(${TmpTestList} PROPERTIES FOLDER "Tests")
else()
gtest_discover_tests(
${TESTNAME}
TEST_PREFIX "${TESTNAME}."
PROPERTIES FOLDER "Tests"
)

endif()
else()
add_test(${TESTNAME} ${TESTNAME})
set_target_properties(${TESTNAME} PROPERTIES FOLDER "Tests")
Expand All @@ -61,8 +88,18 @@ set_target_properties(gtest gtest_main gmock gmock_main PROPERTIES FOLDER "Exter

if(MSVC)
# add_compile_options( /wd4459)
target_compile_definitions(gtest PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
target_compile_definitions(gtest_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
target_compile_definitions(gmock PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
target_compile_definitions(gmock_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING)
if(MSVC_VERSION GREATER_EQUAL 1900)
target_compile_definitions(
gtest PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
)
target_compile_definitions(
gtest_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
)
target_compile_definitions(
gmock PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
)
target_compile_definitions(
gmock_main PUBLIC _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
)
endif()
endif()
1 change: 1 addition & 0 deletions config/spelling_ignorelines.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ThirdParty
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright (c) 2019-2023,
# Copyright (c) 2019-2024,
# Lawrence Livermore National Security, LLC;
# See the top-level NOTICE for additional details. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
2 changes: 1 addition & 1 deletion webserver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright (c) 2019-2023,
# Copyright (c) 2019-2024,
# Lawrence Livermore National Security, LLC;
# See the top-level NOTICE for additional details. All rights reserved.
# SPDX-License-Identifier: BSD-3-Clause
Expand Down

0 comments on commit 400b016

Please sign in to comment.