Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Option to Enable Test Targets #167

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Configure Project
uses: threeal/cmake-action@v1.3.0
with:
options: BUILD_TESTING=ON
options: MY_FIBONACCI_ENABLE_TESTS=ON

- name: Check Formatting
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Configure Project
uses: threeal/cmake-action@v1.3.0
with:
options: BUILD_TESTING=ON
options: MY_FIBONACCI_ENABLE_TESTS=ON

- name: Build Project
run: cmake --build build
Expand Down
10 changes: 4 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ project(
LANGUAGES CXX
)

option(MY_FIBONACCI_ENABLE_TESTS "Enable test targets.")
option(MY_FIBONACCI_ENABLE_INSTALL "Enable install targets."
"${PROJECT_IS_TOP_LEVEL}")

Expand All @@ -22,8 +23,7 @@ function(cpmaddpackage)
cpmaddpackage(${ARGN})
endfunction()

# Enable warning checks if it is not a subproject and testing is enabled.
if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
if(MY_FIBONACCI_ENABLE_TESTS)
find_package(CheckWarning QUIET)
if(NOT CheckWarning_FOUND)
cpmaddpackage(gh:threeal/CheckWarning.cmake@2.1.1)
Expand All @@ -50,8 +50,7 @@ target_compile_features(sequence PRIVATE cxx_std_11)
add_executable(generate_sequence src/main.cpp)
target_link_libraries(generate_sequence PUBLIC argparse::argparse sequence)

# Declare test targets if it is not a subproject and testing is enabled.
if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
if(MY_FIBONACCI_ENABLE_TESTS)
enable_testing()

find_package(ut QUIET)
Expand All @@ -77,8 +76,7 @@ if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
add_test(NAME "Sequence Test" COMMAND sequence_test)
endif()

# Enable automatic formatting if it is not a subproject and testing is enabled.
if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
if(MY_FIBONACCI_ENABLE_TESTS)
find_package(FixFormat QUIET)
if(NOT FixFormat_FOUND)
cpmaddpackage(gh:threeal/FixFormat.cmake@1.1.1)
Expand Down
Loading