From 6201f893846bfd22faf060e84a3bb7bfc0e61761 Mon Sep 17 00:00:00 2001 From: Peter Taylor Date: Fri, 10 Feb 2017 18:37:09 +0000 Subject: [PATCH] Add cmake option to control the build of the example executables. --- CMakeLists.txt | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 157097e..61188e4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project(zlib C) set(VERSION "1.3.0.1") +option(ZLIB_BUILD_EXAMPLES "Enable Zlib Examples" ON) option(ZLIB_STATIC_LINK_CRT "Link the MSVC runtime library statically" OFF) set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") @@ -211,21 +212,22 @@ endif() #============================================================================ # Example binaries #============================================================================ +if(ZLIB_BUILD_EXAMPLES) + add_executable(example test/example.c) + target_link_libraries(example zlib) + add_test(example example) -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) -add_executable(minigzip test/minigzip.c) -target_link_libraries(minigzip zlib) + 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) -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") + add_executable(minigzip64 test/minigzip.c) + target_link_libraries(minigzip64 zlib) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + endif() endif()