1
0
mirror of https://github.com/madler/zlib synced 2025-03-28 21:13:15 +00:00

Use generated zconf.h in cmake build.

This restores the inclusion of the local zconf.h (double quoted)
in normal usage.
This commit is contained in:
Vollstrecker 2025-02-18 08:47:58 +01:00 committed by Mark Adler
parent 7108497fda
commit 5a82f71ed1
3 changed files with 14 additions and 7 deletions

View File

@ -119,7 +119,6 @@ unset(CMAKE_COMPILE_FLAGS)
set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
include_directories(${zlib_BINARY_DIR} ${zlib_SOURCE_DIR})
# ============================================================================
# zlib
@ -172,7 +171,8 @@ if(ZLIB_BUILD_SHARED)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlib
PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
@ -214,7 +214,8 @@ if(ZLIB_BUILD_STATIC)
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlibstatic
PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>

View File

@ -16,6 +16,7 @@ endfunction()
if(ZLIB_BUILD_SHARED)
add_executable(zlib_example example.c)
target_link_libraries(zlib_example ZLIB::ZLIB)
target_compile_definitions(zlib_example PRIVATE ZLIB_BUILD)
add_test(NAME zlib_example COMMAND zlib_example)
add_executable(minigzip minigzip.c)
@ -38,7 +39,7 @@ if(ZLIB_BUILD_SHARED)
add_executable(zlib_example64 example.c)
target_compile_definitions(
zlib_example64
PRIVATE LARGEFILE64_SOURCE=1
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(zlib_example64 ZLIB::ZLIB)
add_test(NAME zlib_example64 COMMAND zlib_example64)
@ -61,7 +62,8 @@ if(ZLIB_BUILD_STATIC)
target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC)
target_compile_definitions(
zlib_static_example
PRIVATE $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
add_test(NAME zlib_static_example COMMAND zlib_static_example)
add_executable(static_minigzip minigzip.c)
@ -116,7 +118,7 @@ if(ZLIB_BUILD_STATIC)
add_executable(zlib_static_example64 example.c)
target_compile_definitions(
zlib_static_example64
PRIVATE LARGEFILE64_SOURCE=1
PRIVATE ZLIB_BUILD
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>)
target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC)
add_test(NAME zlib_static_example64 COMMAND zlib_static_example64)

6
zlib.h
View File

@ -31,7 +31,11 @@
#ifndef ZLIB_H
#define ZLIB_H
#include <zconf.h>
#ifdef ZLIB_BUILD
# include <zconf.h>
#else
# include "zconf.h"
#endif
#ifdef __cplusplus
extern "C" {