Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add inclusion protection #1049

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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