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

Gate CMake tests behind AU_ENABLE_TESTING option #303

Merged
merged 6 commits into from
Oct 21, 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
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,17 @@ project(
LANGUAGES CXX
)

option(AU_ENABLE_TESTING "Build Unit Tests" ON)

# The export set for all of our headers.
set(AU_EXPORT_SET_NAME AuHeaders)

enable_testing()
if(AU_ENABLE_TESTING)
message(STATUS "Unit tests enabled")
enable_testing()
else()
message(STATUS "Unit tests disabled")
endif()

# Bring in GoogleTest so we can build and run the tests.
include(FetchContent)
Expand All @@ -55,6 +62,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)

set(AU_CONFIG_FIND_GTEST_LINE "find_dependency(googletest 1.12.1)")

add_subdirectory(au)

# Configure how Au will be installed.
Expand Down
2 changes: 1 addition & 1 deletion cmake/AuConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)
find_dependency(googletest 1.12.1)
@AU_CONFIG_FIND_GTEST_LINE@

include(${CMAKE_CURRENT_LIST_DIR}/AuHeaders.cmake)

Expand Down
5 changes: 5 additions & 0 deletions cmake/HeaderOnlyLibrary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ function(header_only_library)
endfunction()

function(gtest_based_test)
if (NOT AU_ENABLE_TESTING)
message(VERBOSE "AU_ENABLE_TESTING not defined; will not create test target.")
return()
endif()

#
# Handle argument parsing
#
Expand Down
Loading