Skip to content

Commit

Permalink
fix: Make test executables optional
Browse files Browse the repository at this point in the history
When including zlib as a submodule, it is useful to be able to disable the tests.
  • Loading branch information
joeyparrish committed Nov 9, 2022
1 parent 04f42ce commit 9585b9f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,8 @@ endif()
#============================================================================
# Example binaries
#============================================================================

add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)

add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)
Expand All @@ -205,9 +203,16 @@ if(HAVE_OFF64_T)
add_executable(example64 test/example.c)
target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
add_test(example64 example64)

add_executable(minigzip64 test/minigzip.c)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()

if(BUILD_TESTING)
add_test(example example)

if(HAVE_OFF64_T)
add_test(example64 example64)
endif()
endif()

0 comments on commit 9585b9f

Please sign in to comment.