From: Dan Kegel Date: Thu, 11 Jun 2020 01:41:32 +0000 (-0700) Subject: cmake: generate same zconf.h as configure X-Git-Tag: 1.9.9-b1~204 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=280f379629235921c5782480945236f1d7c8fc78;p=thirdparty%2Fzlib-ng.git cmake: generate same zconf.h as configure Also make comment in zconf.h less configure-specific --- diff --git a/CMakeLists.txt b/CMakeLists.txt index eddf4771a..b759d9add 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -311,10 +311,11 @@ endif() # Check for stndard/system includes # check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(stdarg.h HAVE_STDARG_H) check_include_file(stdint.h HAVE_STDINT_H) check_include_file(stddef.h HAVE_STDDEF_H) check_include_file(sys/sdt.h HAVE_SYS_SDT_H) -check_include_file(unistd.h Z_HAVE_UNISTD_H) +check_include_file(unistd.h HAVE_UNISTD_H) # # Check to see if we have large file support @@ -781,15 +782,13 @@ macro(generate_cmakein input output) file(REMOVE ${output}) file(STRINGS ${input} _lines) foreach(_line IN LISTS _lines) - file(APPEND ${output} "${_line}\n") - - if(_line STREQUAL "#define ZCONF_H" OR _line STREQUAL "#define ZCONFNG_H") - file(APPEND ${output} "#cmakedefine Z_HAVE_UNISTD_H\n") - if(NOT HAVE_PTRDIFF_T) - file(APPEND ${output} "#cmakedefine NEED_PTRDIFF_T\n") - file(APPEND ${output} "#cmakedefine PTRDIFF_TYPE ${PTRDIFF_TYPE}\n") - endif() + string(REGEX REPLACE "#ifdef HAVE_UNISTD_H.*" "@ZCONF_UNISTD_LINE@" _line "${_line}") + string(REGEX REPLACE "#ifdef HAVE_STDARG_H.*" "@ZCONF_STDARG_LINE@" _line "${_line}") + string(REGEX REPLACE "#ifdef NEED_PTRDIFF_T.*" "@ZCONF_PTRDIFF_LINE@" _line "${_line}") + if(NEED_PTRDIFF_T) + string(REGEX REPLACE "typedef PTRDIFF_TYPE" "typedef @PTRDIFF_TYPE@" _line "${_line}") endif() + file(APPEND ${output} "${_line}\n") endforeach() endmacro(generate_cmakein) @@ -975,6 +974,22 @@ if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS) endif() endif() +if(HAVE_STDARG_H) + SET(ZCONF_STDARG_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") +else() + SET(ZCONF_STDARG_LINE "#ifdef HAVE_STDARG_H /* may be set to #if 1 by configure/cmake/etc */") +endif() +if(HAVE_UNISTD_H) + SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") +else() + SET(ZCONF_UNISTD_LINE "#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */") +endif() +if(NEED_PTRDIFF_T) + SET(ZCONF_PTRDIFF_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */") +else() + SET(ZCONF_PTRDIFF_LINE "#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */") +endif() + set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.pc) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY) diff --git a/zconf-ng.h.in b/zconf-ng.h.in index 032c53c01..d2af3d596 100644 --- a/zconf-ng.h.in +++ b/zconf-ng.h.in @@ -98,11 +98,11 @@ typedef void const *voidpc; typedef void *voidpf; typedef void *voidp; -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */ # define Z_HAVE_UNISTD_H #endif -#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by ./configure */ +#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */ typedef PTRDIFF_TYPE ptrdiff_t; #endif diff --git a/zconf.h.in b/zconf.h.in index 15ac26af4..2501330e2 100644 --- a/zconf.h.in +++ b/zconf.h.in @@ -102,11 +102,11 @@ typedef void const *voidpc; typedef void *voidpf; typedef void *voidp; -#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */ # define Z_HAVE_UNISTD_H #endif -#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by ./configure */ +#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */ typedef PTRDIFF_TYPE ptrdiff_t; #endif