Skip to content

Commit

Permalink
Merge pull request InsightSoftwareConsortium#4933 from blowekamp/upda…
Browse files Browse the repository at this point in the history
…te_googletest

Update googletest to 1.15.2
  • Loading branch information
blowekamp authored Nov 6, 2024
2 parents efa9182 + 4c1fa88 commit d78a853
Show file tree
Hide file tree
Showing 32 changed files with 1,538 additions and 1,240 deletions.
2 changes: 1 addition & 1 deletion Modules/ThirdParty/GoogleTest/UpdateFromUpstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ readonly name="GoogleTest"
readonly ownership="GoogleTest Upstream <googletestframework@googlegroups.com>"
readonly subtree="Modules/ThirdParty/GoogleTest/src/itkgoogletest"
readonly repo="https://github.com/google/googletest.git"
readonly tag="v1.13.0"
readonly tag="v1.15.2"
readonly shortlog=false
readonly paths="
CMakeLists.txt
Expand Down
27 changes: 12 additions & 15 deletions Modules/ThirdParty/GoogleTest/src/itkgoogletest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
# Note: CMake support is community-based. The maintainers do not use CMake
# internally.

cmake_minimum_required(VERSION 3.5)

if (POLICY CMP0048)
cmake_policy(SET CMP0048 NEW)
endif (POLICY CMP0048)

if (POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif (POLICY CMP0069)

if (POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif (POLICY CMP0077)
cmake_minimum_required(VERSION 3.13)

project(googletest-distribution)
set(GOOGLETEST_VERSION 1.13.0)
set(GOOGLETEST_VERSION 1.15.2)

if(NOT CYGWIN AND NOT MSYS AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL QNX)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand All @@ -27,11 +15,20 @@ enable_testing()
include(CMakeDependentOption)
include(GNUInstallDirs)

#Note that googlemock target already builds googletest
# Note that googlemock target already builds googletest.
option(BUILD_GMOCK "Builds the googlemock subproject" ON)
option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF)

if(GTEST_HAS_ABSL)
if(NOT TARGET absl::base)
find_package(absl REQUIRED)
endif()
if(NOT TARGET re2::re2)
find_package(re2 REQUIRED)
endif()
endif()

if(BUILD_GMOCK)
add_subdirectory( googlemock )
else()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# CMake build script for Google Test.
#
# To run the tests for Google Test itself on Linux, use 'make test' or
# ctest. You can select which tests to run using 'ctest -R regex'.
# ctest. You can select which tests to run using 'ctest -R regex'.
# For more options, run 'ctest --help'.

# When other libraries are using a shared version of runtime libraries,
Expand Down Expand Up @@ -36,7 +36,7 @@ endif()

########################################################################
#
# Project-wide settings
# Project-wide settings.

# Name of the project.
#
Expand All @@ -45,21 +45,16 @@ endif()
# ${gtest_BINARY_DIR}.
# Language "C" is required for find_package(Threads).

# Project version:
# Project version.

cmake_minimum_required(VERSION 3.5)
cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.13)
project(gtest VERSION ${GOOGLETEST_VERSION} LANGUAGES CXX C)

if (POLICY CMP0063) # Visibility
cmake_policy(SET CMP0063 NEW)
endif (POLICY CMP0063)

if (COMMAND set_up_hermetic_build)
set_up_hermetic_build()
endif()

# These commands only run if this is the main project
# These commands only run if this is the main project.
if(CMAKE_PROJECT_NAME STREQUAL "gtest" OR CMAKE_PROJECT_NAME STREQUAL "googletest-distribution")

# BUILD_SHARED_LIBS is a standard CMake variable, but we declare it here to
Expand Down Expand Up @@ -89,7 +84,7 @@ include(cmake/internal_utils.cmake)
config_compiler_and_linker() # Defined in internal_utils.cmake.

# Needed to set the namespace for both the export targets and the
# alias libraries
# alias libraries.
set(cmake_package_name GTest CACHE INTERNAL "")

# Create the CMake package file descriptors.
Expand All @@ -101,12 +96,14 @@ if (INSTALL_GTEST)
set(version_file "${generated_dir}/${cmake_package_name}ConfigVersion.cmake")
write_basic_package_version_file(${version_file} VERSION ${GOOGLETEST_VERSION} COMPATIBILITY AnyNewerVersion)
install(EXPORT ${targets_export_name}
COMPONENT "${PROJECT_NAME}"
NAMESPACE ${cmake_package_name}::
DESTINATION ${cmake_files_install_dir})
set(config_file "${generated_dir}/${cmake_package_name}Config.cmake")
configure_package_config_file("${gtest_SOURCE_DIR}/cmake/Config.cmake.in"
"${config_file}" INSTALL_DESTINATION ${cmake_files_install_dir})
install(FILES ${version_file} ${config_file}
COMPONENT "${PROJECT_NAME}"
DESTINATION ${cmake_files_install_dir})
endif()

Expand All @@ -118,10 +115,10 @@ include_directories(${gtest_build_include_dirs})

########################################################################
#
# Defines the gtest & gtest_main libraries. User tests should link
# Defines the gtest & gtest_main libraries. User tests should link
# with one of them.

# Google Test libraries. We build them using more strict warnings than what
# Google Test libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that gtest can be compiled by a user
# aggressive about warnings.
cxx_library(gtest "${cxx_strict}" src/gtest-all.cc)
Expand All @@ -144,34 +141,29 @@ if(GTEST_HAS_ABSL)
endif()
cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION})
# If the CMake version supports it, attach header directory information
# to the targets for when we are part of a parent build (ie being pulled
# in via add_subdirectory() rather than being a standalone build).
if (DEFINED CMAKE_VERSION AND NOT "${CMAKE_VERSION}" VERSION_LESS "2.8.11")
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
target_include_directories(gtest SYSTEM INTERFACE
"$<BUILD_INTERFACE:${dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(gtest_main SYSTEM INTERFACE
"$<BUILD_INTERFACE:${dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
endif()
if(CMAKE_SYSTEM_NAME MATCHES "QNX")
string(REPLACE ";" "$<SEMICOLON>" dirs "${gtest_build_include_dirs}")
target_include_directories(gtest SYSTEM INTERFACE
"$<BUILD_INTERFACE:${dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(gtest_main SYSTEM INTERFACE
"$<BUILD_INTERFACE:${dirs}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")
if(CMAKE_SYSTEM_NAME MATCHES "QNX" AND CMAKE_SYSTEM_VERSION VERSION_GREATER_EQUAL 7.1)
target_link_libraries(gtest PUBLIC regex)
endif()
target_link_libraries(gtest_main PUBLIC gtest)

########################################################################
#
# Install rules
# Install rules.
install_project(gtest gtest_main)

########################################################################
#
# Samples on how to link user tests with gtest or gtest_main.
#
# They are not built by default. To build them, set the
# gtest_build_samples option to ON. You can do it by running ccmake
# They are not built by default. To build them, set the
# gtest_build_samples option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_samples=ON flag when running cmake.

if (gtest_build_samples)
Expand All @@ -194,8 +186,8 @@ endif()
# You can skip this section if you aren't interested in testing
# Google Test itself.
#
# The tests are not built by default. To build them, set the
# gtest_build_tests option to ON. You can do it by running ccmake
# The tests are not built by default. To build them, set the
# gtest_build_tests option to ON. You can do it by running ccmake
# or specifying the -Dgtest_build_tests=ON flag when running cmake.

if (gtest_build_tests)
Expand Down Expand Up @@ -277,7 +269,7 @@ if (gtest_build_tests)
py_test(gtest_skip_environment_check_output_test)

# Visual Studio .NET 2003 does not support STL with exceptions disabled.
if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
if (NOT MSVC OR MSVC_VERSION GREATER 1310) # 1310 is Visual Studio .NET 2003
cxx_executable_with_flags(
googletest-catch-exceptions-no-ex-test_
"${cxx_no_exception}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ if (@GTEST_HAS_PTHREAD@)
set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@)
find_dependency(Threads)
endif()
if (@GTEST_HAS_ABSL@)
find_dependency(absl)
find_dependency(re2)
endif()

include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("@project_name@")
Loading

0 comments on commit d78a853

Please sign in to comment.