diff --git a/CMakeLists.txt b/CMakeLists.txt index b18407ff..08ea4119 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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. diff --git a/cmake/AuConfig.cmake.in b/cmake/AuConfig.cmake.in index b121f76f..4b86f686 100644 --- a/cmake/AuConfig.cmake.in +++ b/cmake/AuConfig.cmake.in @@ -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) diff --git a/cmake/HeaderOnlyLibrary.cmake b/cmake/HeaderOnlyLibrary.cmake index 3c49527d..eafd4d1a 100644 --- a/cmake/HeaderOnlyLibrary.cmake +++ b/cmake/HeaderOnlyLibrary.cmake @@ -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 #