Skip to content

Commit 704843d

Browse files
committed
Add BUILD_TESTING cmake option
As with CTest, but without the full machinery thereof. This facilitates package builders to use the usual build targets (all, install) without needing to build the test programs if they're just going to get dropped on the floor.
1 parent 74becb8 commit 704843d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ include(CheckIncludeFileCXX)
1212
include(CheckIPOSupported)
1313
include(CMakeDependentOption)
1414

15+
# Name chosen for compatibility with CTest.
16+
option(BUILD_TESTING "Build test programs as well as shims" ON)
17+
1518
option(SNMALLOC_HEADER_ONLY_LIBRARY "Use snmalloc has a header-only library" OFF)
1619
# Options that apply globally
1720
option(SNMALLOC_CI_BUILD "Disable features not sensible for CI" OFF)
@@ -373,10 +376,15 @@ if(NOT SNMALLOC_HEADER_ONLY_LIBRARY)
373376
target_compile_definitions(snmallocshim-checks-rust PRIVATE SNMALLOC_CHECK_CLIENT)
374377
endif()
375378

376-
enable_testing()
377-
378379
set(TESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/src/test)
379-
subdirlist(TEST_CATEGORIES ${TESTDIR})
380+
381+
if(BUILD_TESTING)
382+
enable_testing()
383+
subdirlist(TEST_CATEGORIES ${TESTDIR})
384+
else()
385+
set(TEST_CATEGORIES "")
386+
endif()
387+
380388
list(REVERSE TEST_CATEGORIES)
381389
if (${SNMALLOC_CLEANUP} STREQUAL THREAD_CLEANUP)
382390
set(TEST_CLEANUP PTHREAD_DESTRUCTORS)

0 commit comments

Comments
 (0)