Skip to content

Commit

Permalink
CMake: Build tests only on make test
Browse files Browse the repository at this point in the history
Add EXCLUDE_FROM_ALL to test binaries as per the Boost convention
  • Loading branch information
Flamefire committed May 14, 2024
1 parent 5acfcda commit 2ee28b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2019 - 2022 Alexander Grund
# Copyright 2019 - 2024 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt

Expand Down Expand Up @@ -102,8 +102,8 @@ jobs:
extraFlags="$extraFlags -DCMAKE_CXX_FLAGS=-Wundef"
fi
cmake -DCMAKE_BUILD_TYPE=${{matrix.buildType}} -DBUILD_SHARED_LIBS=${{matrix.shared_lib}} -G "${{matrix.generator}}" $extraFlags ..
- name: Build & Install
run: cmake --build build --config ${{matrix.buildType}} --target install
- name: Build
run: cmake --build build --config ${{matrix.buildType}} --target tests

# Run test with both bash and powershell and watch for "Using std::cin" on bash but not on powershell
- name: Test
Expand All @@ -114,6 +114,9 @@ jobs:
shell: powershell
if: runner.os == 'Windows'
run: ctest --output-on-failure -C ${{matrix.buildType}} --verbose

- name: Install
run: cmake --build build --config ${{matrix.buildType}} --target install
- name: Test consumption
working-directory: build
run: |
Expand Down
6 changes: 3 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Copyright 2019 - 2021 Alexander Grund
# Copyright 2019 - 2024 Alexander Grund
# Distributed under the Boost Software License, Version 1.0.
# https://www.boost.org/LICENSE_1_0.txt

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wsuggest-override _BOOST_NOWIDE_SUGGEST_OVERRIDE_SUPPORTED)

add_library(boost_nowide_file_test_helpers STATIC file_test_helpers.cpp)
add_library(boost_nowide_file_test_helpers STATIC EXCLUDE_FROM_ALL file_test_helpers.cpp)
target_link_libraries(boost_nowide_file_test_helpers PRIVATE Boost::nowide)
target_compile_definitions(boost_nowide_file_test_helpers PRIVATE BOOST_ALL_NO_LIB)

Expand All @@ -27,7 +27,7 @@ function(boost_nowide_add_test name)
endif()
set(name ${PROJECT_NAME}-${name})

add_executable(${name} ${ARG_SRC})
add_executable(${name} EXCLUDE_FROM_ALL ${ARG_SRC})
add_dependencies(tests ${name})
target_link_libraries(${name} PRIVATE Boost::nowide ${ARG_LIBRARIES})
boost_add_warnings(${name} pedantic ${Boost_NOWIDE_WERROR})
Expand Down

0 comments on commit 2ee28b5

Please sign in to comment.