Skip to content

Commit

Permalink
Replace BUILD_TESTS CMake option with ENABLE_TESTS variable which all…
Browse files Browse the repository at this point in the history
…ows to specify multiple test types
  • Loading branch information
danielkrupinski committed Jan 29, 2025
1 parent 9971ff5 commit d2117d7
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
sudo ./llvm.sh 19
echo "CXXFLAGS=\"--gcc-install-dir=/usr/lib/gcc/x86_64-linux-gnu/13\"" >> "$GITHUB_ENV"
- name: configure
run: CXX=${{ matrix.compiler }} cmake -Werror=dev -D CMAKE_BUILD_TYPE=${{ matrix.configuration }} -D BUILD_TESTS=1 -D CMAKE_COMPILE_WARNING_AS_ERROR=1 -B build
run: CXX=${{ matrix.compiler }} cmake -Werror=dev -D CMAKE_BUILD_TYPE=${{ matrix.configuration }} -D ENABLE_TESTS="unit" -D CMAKE_COMPILE_WARNING_AS_ERROR=1 -B build
- name: build source
run: cmake --build build --target Osiris -j $(nproc --all)
- name: build unit tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
if: matrix.toolset == 'ClangCL'
run: echo "toolset=-T ${{ matrix.toolset }}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: configure
run: cmake -Werror=dev -D BUILD_TESTS=1 -D CMAKE_COMPILE_WARNING_AS_ERROR=1 -A x64 ${{ env.toolset }} -B build
run: cmake -Werror=dev -D ENABLE_TESTS="unit" -D CMAKE_COMPILE_WARNING_AS_ERROR=1 -A x64 ${{ env.toolset }} -B build
- name: build source
run: cmake --build build --target Osiris --config ${{ matrix.configuration }}
- name: build unit tests
Expand Down
10 changes: 3 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ elseif(UNIX)
enable_language(ASM-ATT)
endif()

add_subdirectory(Source)

option(BUILD_TESTS "Build unit tests" OFF)
set(ENABLE_TESTS CACHE STRING "List of test types to enable e.g. \"unit\"")

if (BUILD_TESTS)
enable_testing()
add_subdirectory(Tests)
endif()
add_subdirectory(Source)
add_subdirectory(Tests)
28 changes: 15 additions & 13 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
set(THREADS_PREFER_PTHREAD_FLAG ON)
if("unit" IN_LIST ENABLE_TESTS)
enable_testing()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

find_package(Threads REQUIRED)
include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # v1.14.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(googletest)

include(FetchContent)
FetchContent_Declare(
googletest
GIT_REPOSITORY https://github.com/google/googletest.git
GIT_TAG f8d7d77c06936315286eb55f8de22cd23c188571 # v1.14.0
GIT_SHALLOW TRUE
)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)

include(GoogleTest)

add_subdirectory(UnitTests)
add_subdirectory(UnitTests)
endif()

0 comments on commit d2117d7

Please sign in to comment.