Skip to content

Commit

Permalink
Switch GTest to use FetchContent rather than a submodule.
Browse files Browse the repository at this point in the history
Fixes #40
Supersedes #41
  • Loading branch information
zrax committed Oct 15, 2024
1 parent e20cd98 commit edf3407
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

10 changes: 2 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,12 @@
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.

cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
project(string_theory)

# We will detect and use optional features in newer C++ standards,
# but C++11 is required at minimum
if(${CMAKE_VERSION} VERSION_GREATER "3.11.99")
set(CMAKE_CXX_STANDARD 20)
elseif(${CMAKE_VERSION} VERSION_GREATER "3.7.99")
set(CMAKE_CXX_STANDARD 17)
else()
set(CMAKE_CXX_STANDARD 14)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED OFF)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
17 changes: 6 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ set(gtest_hide_internal_symbols ON CACHE INTERNAL "Override gtest default")

set(BUILD_GMOCK OFF CACHE INTERNAL "Override gtest default" FORCE)
set(INSTALL_GTEST OFF CACHE INTERNAL "Override gtest default" FORCE)
add_subdirectory(gtest EXCLUDE_FROM_ALL)

if(CMAKE_COMPILER_IS_GNUCXX)
# Squash an error in gtest that surfaced in GCC 12
target_compile_options(gtest PRIVATE -Wno-restrict)
endif()
include(FetchContent)
FetchContent_Declare(gtest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG v1.15.2
)
FetchContent_MakeAvailable(gtest)

add_executable(st_gtests "")
target_link_libraries(st_gtests PRIVATE gtest gtest_main string_theory)
Expand Down Expand Up @@ -124,11 +125,5 @@ if(ST_BUILD_PROFILE_TEST)
endif()

cmake_policy(PUSH)
if(${CMAKE_VERSION} VERSION_LESS "3.11" AND POLICY CMP0037)
# The "test" target is reserved when ctest is included (CMake 3.11+),
# but older versions of CMake will reserve it always, so we must
# explicitly allow older CMake versions to allow the target name
cmake_policy(SET CMP0037 OLD)
endif()
add_custom_target(test "$<TARGET_FILE:st_gtests>")
cmake_policy(POP)
1 change: 0 additions & 1 deletion test/gtest
Submodule gtest deleted from 58d77f

0 comments on commit edf3407

Please sign in to comment.