Skip to content

Commit

Permalink
Split build producation vs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
neatudarius committed Jun 29, 2024
1 parent 248adc8 commit ed29cdf
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
9 changes: 6 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions extern/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion extern/googletest
Submodule googletest deleted from 305e5a
17 changes: 3 additions & 14 deletions src/Beman/Optional26/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
29 changes: 29 additions & 0 deletions src/Beman/Optional26/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit ed29cdf

Please sign in to comment.