Skip to content

Commit

Permalink
Split build production vs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
neatudarius committed Jun 29, 2024
1 parent 8f4a5f4 commit 828cb17
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 33 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ 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: |
set -x
Expand Down
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
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,30 @@
# 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()

# Fetch GoogleTest
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # release-1.14.0
)
FetchContent_MakeAvailable(googletest)
endif()

add_subdirectory(src)
add_subdirectory(examples)

Expand Down
10 changes: 9 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"binaryDir": "${sourceDir}/.build/${presetName}",
"installDir": "${sourceDir}/.install/${presetName}",
"cacheVariables": {
"CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo;Debug;Tsan;Asan"
"CMAKE_CONFIGURATION_TYPES": "RelWithDebInfo;Debug;Tsan;Asan",
"CMAKE_BUILD_TESTS": true
}
},
{
Expand Down Expand Up @@ -68,33 +69,40 @@
},
{
"name": "system",
"inherits": "common",
"configurePreset": "system"
},
{
"name": "gcc-14",
"inherits": "common",
"configurePreset": "gcc-14"
},
{
"name": "gcc-13",
"inherits": "common",
"configurePreset": "gcc-13"
},
{
"name": "clang-19",
"inherits": "common",
"configurePreset": "clang-19"
},
{
"name": "clang-18",
"inherits": "common",
"configurePreset": "clang-18"
},
{
"name": "clang-17",
"inherits": "common",
"configurePreset": "clang-17"
}
],
"testPresets": [
{
"name": "common",
"hidden": true,
"configuration": "Asan",
"output": {
"outputOnFailure": true
},
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
21 changes: 3 additions & 18 deletions src/Beman/Optional26/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +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)

# Note: clang-19 + gtest_discover_tests + Asan setup causes errors on some platforms.
# Temporary switch to gtest_add_tests and skip some Asan checks.
enable_testing()
gtest_add_tests(optional_test "" AUTO)
if("${CMAKE_BUILD_TESTS}")
add_subdirectory(tests)
endif()
22 changes: 22 additions & 0 deletions src/Beman/Optional26/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# cmake-format: off
# src/Beman/Optional26/tests/CMakeLists.txt -*-makefile-*-
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
# cmake-format: on

# 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)

# Note: clang-19 + gtest_discover_tests + Asan setup causes errors on some platforms.
# Temporary switch to gtest_add_tests and skip some Asan checks.
enable_testing()
gtest_add_tests(optional_test "" AUTO)

0 comments on commit 828cb17

Please sign in to comment.