Skip to content

Commit 7e62b40

Browse files
committed
Add option to enable testing defaulting to TRUE when top level.
This fixes an issue where testing wasn't enabled by default. I followed the suggestion made at bemanproject/exemplar#60 (comment)
1 parent b041327 commit 7e62b40

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ option(BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS
1212
"Make use of deducing this. Turn this off for non-conforming compilers."
1313
${COMPILER_SUPPORTS_DEDUCING_THIS})
1414

15+
option(BEMAN_ITERATOR_INTERFACE26_ENABLE_TESTING "Build beman.iterator_interface26 tests" ${PROJECT_IS_TOP_LEVEL})
16+
1517
if(BEMAN_ITERATOR_INTERFACE26_USE_DEDUCING_THIS AND NOT COMPILER_SUPPORTS_DEDUCING_THIS)
1618
message(WARNING "Building with deducing this support despite of the compiler's lack of support for it")
1719
endif()
@@ -22,7 +24,9 @@ configure_file(
2224
@ONLY
2325
)
2426

25-
enable_testing()
27+
if(BEMAN_ITERATOR_INTERFACE26_ENABLE_TESTING)
28+
enable_testing()
29+
endif()
2630

2731
set(TARGETS_EXPORT_NAME ${CMAKE_PROJECT_NAME}Targets)
2832

extern/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if(BUILD_TESTING)
1+
if(BEMAN_ITERATOR_INTERFACE26_ENABLE_TESTING)
22
# Fetch GoogleTest
33
FetchContent_Declare(
44
googletest

src/beman/iterator_interface26/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ install(
3333
target_link_libraries(beman.iterator_interface26)
3434

3535
## Tests
36-
if(BUILD_TESTING)
36+
if(BEMAN_ITERATOR_INTERFACE26_ENABLE_TESTING)
3737
add_executable(iterator_interface_test "")
3838

3939
target_sources(

0 commit comments

Comments
 (0)