@@ -73,34 +73,43 @@ target_compile_definitions(
7373 $<$<AND :$<PLATFORM_ID:Windows>,$<IN_LIST :$<TARGET_PROPERTY:TYPE >,MODULE_LIBRARY;SHARED_LIBRARY>>:PHP_BZ2_EXPORTS>
7474)
7575
76- find_package (BZip2 ${PHP_BZIP2_MIN_VERSION} )
76+ find_package (BZip2 1.0.0 )
7777set_package_properties(
7878 BZip2
7979 PROPERTIES
8080 TYPE REQUIRED
8181 PURPOSE "Necessary to enable the bz2 extension."
8282)
8383
84- # Link with PUBLIC scope if include directories are on non-standard places.
85- target_link_libraries (php_ext_bz2 PUBLIC BZip2::BZip2)
86-
8784# Minimum version sanity check.
8885if (TARGET BZip2::BZip2)
8986 cmake_push_check_state(RESET)
9087 set (CMAKE_REQUIRED_LIBRARIES BZip2::BZip2)
9188
92- check_symbol_exists(BZ2_bzerror bzlib.h _PHP_HAVE_BZ2_BZERROR)
93-
94- if (NOT _PHP_HAVE_BZ2_BZERROR)
89+ # bzip versions 1.0.1 and earlier required <stdio.h> to be included before
90+ # bzlib.h, to have FILE definition. In 1.0.4, minor version (4) has been
91+ # updated in the bzlib.h header. BZ2_bzerror() is available as of 1.0.0.
92+ block()
93+ set (headers "bzlib.h" )
94+ if (BZip2_VERSION VERSION_LESS 1.0.4)
95+ list (PREPEND headers "stdio.h" )
96+ endif ()
97+ check_symbol_exists(BZ2_bzerror "${headers} " PHP_EXT_BZ2_SANITY_CHECK)
98+ endblock()
99+
100+ if (NOT PHP_EXT_BZ2_SANITY_CHECK)
95101 message (
96102 FATAL_ERROR
97- "BZip2 package is not working as expected. The bz2 extension requires "
98- "BZip2 library (libbzip2) version ${PHP_BZIP2_MIN_VERSION} or later."
103+ "ext/bz2 sanity check failed: BZ2_bzerror() could not be found. "
104+ "BZip2 library (libbzip2) version 1.0.0 or later is required ."
99105 )
100106 endif ()
101107 cmake_pop_check_state()
102108endif ()
103109
110+ # Link with PUBLIC scope if include directories are on non-standard places.
111+ target_link_libraries (php_ext_bz2 PUBLIC BZip2::BZip2)
112+
104113set (HAVE_BZ2 TRUE )
105114
106115configure_file (cmake/config.h.in config.h)
0 commit comments