From 31d2462c1df539e6bb9bedc987ba991672a1906e Mon Sep 17 00:00:00 2001 From: Vollstrecker Date: Sun, 1 Dec 2024 16:52:59 +0100 Subject: [PATCH] CMake: Move compile_definitions to the targets. --- CMakeLists.txt | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a0e4d83..20eaa9e1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,31 +24,19 @@ enable_testing() # Check to see if we have large file support # set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) - check_type_size(off64_t OFF64_T) -if(HAVE_OFF64_T) - add_definitions(-D_LARGEFILE64_SOURCE=1) -endif() set(CMAKE_REQUIRED_DEFINITIONS) # clear variable # # Check for fseeko # check_function_exists(fseeko HAVE_FSEEKO) -if(NOT HAVE_FSEEKO) - add_definitions(-DNO_FSEEKO) -endif() # # Check for unistd.h # check_include_file(unistd.h Z_HAVE_UNISTD_H) -if(MSVC) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) - add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) -endif() - set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc) configure_file( ${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY) @@ -130,6 +118,12 @@ if(ZLIB_BUILD_SHARED) target_include_directories(zlib PUBLIC $ $) + target_compile_definitions(zlib + PRIVATE + $<$:_LARGEFILE64_SOURCE=1> + $<$:NO_FSEEKO> + $<$:_CRT_SECURE_NO_DEPRECATE> + $<$:_CRT_NONSTDC_NO_DEPRECATE>) set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL SOVERSION 1 @@ -147,6 +141,13 @@ if(ZLIB_BUILD_STATIC) target_include_directories(zlibstatic PUBLIC $ $) + target_compile_definitions(zlibstatic + PRIVATE + $<$:NO_FSEEKO> + $<$:_CRT_SECURE_NO_DEPRECATE> + $<$:_CRT_NONSTDC_NO_DEPRECATE> + PUBLIC + $<$:_LARGEFILE64_SOURCE=1>) set_target_properties(zlibstatic PROPERTIES PROPERTIES OUTPUT_NAME z${zlib_static_suffix} PROPERTIES OUTPUT_NAME_DEBUG z${zlib_static_suffix}${zlib_debug_suffix})