]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
cmake: generate same zconf.h as configure
authorDan Kegel <dank@kegel.com>
Thu, 11 Jun 2020 01:41:32 +0000 (18:41 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Fri, 19 Jun 2020 08:14:35 +0000 (10:14 +0200)
Also make comment in zconf.h less configure-specific

CMakeLists.txt
zconf-ng.h.in
zconf.h.in

index eddf4771a9a42d46043ce1fbb37e00001fa18113..b759d9add364c7872dff156cf908677fb53a58c4 100644 (file)
@@ -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)
index 032c53c01a962c6f85f3133c833d1f1ccd9e0c60..d2af3d59661b56527deb9c208296574ce3aa89e7 100644 (file)
@@ -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
 
index 15ac26af4088ea1cd52f8646eaa5cb26fa62a9e2..2501330e2f3c4b108066b770f80f94ffbdc78088 100644 (file)
@@ -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