diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a5a38bf..5f7c5df9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -62,11 +62,11 @@ jobs: cd .build echo ${{ matrix.config.cmake_args }} echo ${{ matrix.config.toolchain }} - cmake ${{ matrix.config.cmake_args }} -DCMAKE_TOOLCHAIN_FILE=etc/${{ matrix.config.toolchain }} -B . -S .. + cmake ${{ matrix.config.cmake_args }} -DCMAKE_TOOLCHAIN_FILE=etc/${{ matrix.config.toolchain }} -DCMAKE_BUILD_TESTS=true -B . -S .. - name: Build run: | cmake --build .build --config Asan --target all -- -k 0 - name: Test run: | cd .build - ctest --output-on-failure + ctest --output-on-failure --build-config Asan diff --git a/.gitmodules b/.gitmodules index 9c4e4556..b44d8c09 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ [submodule "papers/wg21"] path = papers/P2988/wg21 url = https://github.com/mpark/wg21.git -[submodule "extern/googletest"] - path = extern/googletest - url = https://github.com/google/googletest.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 564e9d76..cf94a099 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,18 +3,21 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception # cmake-format: on -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.27) project( beman_optional26 VERSION 0.0.0 LANGUAGES CXX) -enable_testing() +cmake_policy(VERSION 3.27) set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets) -add_subdirectory(extern) +if("${CMAKE_BUILD_TESTS}") + enable_testing() +endif() + add_subdirectory(src) add_subdirectory(examples) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt deleted file mode 100644 index 31f2a6fc..00000000 --- a/extern/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# cmake-format: off -# extern/CMakeLists.txt -*-makefile-*- -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# cmake-format: on - -add_subdirectory(googletest EXCLUDE_FROM_ALL) diff --git a/extern/googletest b/extern/googletest deleted file mode 160000 index 305e5a23..00000000 --- a/extern/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 305e5a238b3c8d11266fbafd85520fb6b3184851 diff --git a/src/Beman/Optional26/CMakeLists.txt b/src/Beman/Optional26/CMakeLists.txt index 59e00a89..28393cbe 100644 --- a/src/Beman/Optional26/CMakeLists.txt +++ b/src/Beman/Optional26/CMakeLists.txt @@ -35,17 +35,6 @@ install( target_link_libraries("${TARGET_LIBRARY}") # Tests -add_executable(optional_test "") - -target_sources( - optional_test - PRIVATE tests/optional.t.cpp tests/optional_ref.t.cpp - tests/optional_monadic.t.cpp tests/optional_range_support.t.cpp - tests/optional_ref_monadic.t.cpp tests/detail/iterator.t.cpp) - -target_link_libraries(optional_test "${TARGET_LIBRARY}") -target_link_libraries(optional_test gtest) -target_link_libraries(optional_test gtest_main) - -include(GoogleTest) -gtest_discover_tests(optional_test) +if("${CMAKE_BUILD_TESTS}") + add_subdirectory(tests) +endif() diff --git a/src/Beman/Optional26/tests/CMakeLists.txt b/src/Beman/Optional26/tests/CMakeLists.txt new file mode 100644 index 00000000..a40b5e6b --- /dev/null +++ b/src/Beman/Optional26/tests/CMakeLists.txt @@ -0,0 +1,29 @@ +# cmake-format: off +# src/Beman/Optional26/tests/CMakeLists.txt -*-makefile-*- +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# cmake-format: on + +include(FetchContent) +FetchContent_Declare( + googletest + URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip +) +# For Windows: Prevent overriding the parent project's compiler/linker settings +set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) +FetchContent_MakeAvailable(googletest) + +enable_testing() + +# Tests +add_executable(optional_test "") + +target_sources( + optional_test + PRIVATE optional.t.cpp optional_ref.t.cpp + optional_monadic.t.cpp optional_range_support.t.cpp + optional_ref_monadic.t.cpp detail/iterator.t.cpp) + +target_link_libraries(optional_test "${TARGET_LIBRARY}" GTest::gtest GTest::gtest_main) + +include(GoogleTest) +gtest_add_tests(optional_test "" AUTO)