Skip to content

Commit e16c9d1

Browse files
emaxerrnolemire
authored andcommitted
CMake: allow parent project to disable unit tests for streamvbyte (#22)
While integrating into another cmake project via add_subdirectory() the target `check` might already be defined by a parent directory. In addition, on a parent project when you run its unit tests you don't want child project unit tests to run
1 parent 92eda80 commit e16c9d1

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

CMakeLists.txt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.3)
22
project(STREAMVBYTE VERSION "0.0.1")
33
cmake_policy(SET CMP0065 OLD)
4-
enable_testing()
54
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
65
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -v" )
76
set(BASE_FLAGS
@@ -71,9 +70,12 @@ target_link_libraries (writeseq streamvbyte_static)
7170
add_executable (unit ${PROJECT_SOURCE_DIR}/tests/unit.c)
7271
target_link_libraries (unit streamvbyte_static)
7372

74-
75-
# add unit tests
76-
add_test(NAME unit COMMAND unit)
77-
add_custom_target(check
78-
COMMAND ctest --output-on-failure
79-
DEPENDS unit)
73+
option(STREAMVBYTE_ENABLE_TESTS "enable unit tests for streamvbyte" ON)
74+
if(STREAMVBYTE_ENABLE_TESTS)
75+
enable_testing()
76+
# add unit tests
77+
add_test(NAME unit COMMAND unit)
78+
add_custom_target(check
79+
COMMAND ctest --output-on-failure
80+
DEPENDS unit)
81+
endif()

0 commit comments

Comments
 (0)