Skip to content

Commit 6201f89

Browse files
Peter Taylormadler
Peter Taylor
authored andcommitted
Add cmake option to control the build of the example executables.
1 parent 14a5f8f commit 6201f89

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

CMakeLists.txt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ project(zlib C)
99

1010
set(VERSION "1.3.0.1")
1111

12+
option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON)
1213
option(ZLIB_STATIC_LINK_CRT "Link the MSVC runtime library statically" OFF)
1314

1415
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
@@ -211,21 +212,22 @@ endif()
211212
#============================================================================
212213
# Example binaries
213214
#============================================================================
214-
215-
add_executable(example test/example.c)
216-
target_link_libraries(example zlib)
217-
add_test(example example)
218-
219-
add_executable(minigzip test/minigzip.c)
220-
target_link_libraries(minigzip zlib)
221-
222-
if(HAVE_OFF64_T)
223-
add_executable(example64 test/example.c)
224-
target_link_libraries(example64 zlib)
225-
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
226-
add_test(example64 example64)
227-
228-
add_executable(minigzip64 test/minigzip.c)
229-
target_link_libraries(minigzip64 zlib)
230-
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
215+
if(ZLIB_BUILD_EXAMPLES)
216+
add_executable(example test/example.c)
217+
target_link_libraries(example zlib)
218+
add_test(example example)
219+
220+
add_executable(minigzip test/minigzip.c)
221+
target_link_libraries(minigzip zlib)
222+
223+
if(HAVE_OFF64_T)
224+
add_executable(example64 test/example.c)
225+
target_link_libraries(example64 zlib)
226+
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
227+
add_test(example64 example64)
228+
229+
add_executable(minigzip64 test/minigzip.c)
230+
target_link_libraries(minigzip64 zlib)
231+
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
232+
endif()
231233
endif()

0 commit comments

Comments
 (0)