Skip to content

Commit

Permalink
Use generated zconf.h in cmake build.
Browse files Browse the repository at this point in the history
This restores the inclusion of the local zconf.h (double quoted)
in normal usage.
  • Loading branch information
Vollstrecker authored and madler committed Feb 18, 2025
1 parent 7108497 commit 5a82f71
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
8 changes: 5 additions & 3 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion zlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down

0 comments on commit 5a82f71

Please sign in to comment.