diff --git a/src/mono/cmake/configure.cmake b/src/mono/cmake/configure.cmake index b3d3f47c894e0b..d27fc5201202a1 100644 --- a/src/mono/cmake/configure.cmake +++ b/src/mono/cmake/configure.cmake @@ -6,6 +6,7 @@ include(CheckTypeSize) include(CheckStructHasMember) include(CheckSymbolExists) include(CheckCCompilerFlag) +include(CheckCSourceCompiles) # Apple platforms like macOS/iOS allow targeting older operating system versions with a single SDK, # the mere presence of a symbol in the SDK doesn't tell us whether the deployment target really supports it. @@ -79,6 +80,21 @@ ac_check_funcs ( gethrtime read_real_time gethostbyname gethostbyname2 getnameinfo getifaddrs access inet_ntop Qp2getifaddrs) +check_c_source_compiles( + " + #include + int main(void) + { + #if defined(ZLIB_VERNUM) && (ZLIB_VERNUM >= 0x1230) + #else + #error No good zlib found + #endif + return 0; + } + " + HAVE_SYS_ZLIB) + + if(NOT HOST_DARWIN) # getentropy was introduced in macOS 10.12 / iOS 10.0 ac_check_funcs (getentropy) diff --git a/src/mono/cmake/defines-todo.cmake b/src/mono/cmake/defines-todo.cmake index 55c5b6f85bb625..5f48e9d70b4fd3 100644 --- a/src/mono/cmake/defines-todo.cmake +++ b/src/mono/cmake/defines-todo.cmake @@ -25,7 +25,6 @@ #option (NEED_LINK_UNLINK "Define if Unix sockets cannot be created in an anonymous namespace") #option (HAVE_CLASSIC_WINAPI_SUPPORT "Use classic Windows API support") #option (HAVE_UWP_WINAPI_SUPPORT "Don't use UWP Windows API support") -#option (HAVE_SYS_ZLIB "Use OS-provided zlib") #option (MONO_XEN_OPT "Xen-specific behaviour") #option (MONO_SMALL_CONFIG "Reduce runtime requirements (and capabilities)") #option (AC_APPLE_UNIVERSAL_BUILD "Define if building universal (internal helper macro)") diff --git a/src/mono/mono/mini/CMakeLists.txt b/src/mono/mono/mini/CMakeLists.txt index f4deeadb0ccbf7..54a5e44096a111 100644 --- a/src/mono/mono/mini/CMakeLists.txt +++ b/src/mono/mono/mini/CMakeLists.txt @@ -44,8 +44,10 @@ include(../eglib/CMakeLists.txt) include(../utils/CMakeLists.txt) include(../metadata/CMakeLists.txt) include(../sgen/CMakeLists.txt) -if(INTERNAL_ZLIB) # TODO: hook up HAVE_SYS_ZLIB instead +if(INTERNAL_ZLIB) include(../zlib/CMakeLists.txt) +elseif(HAVE_SYS_ZLIB) + set(Z_LIBS z) endif() include(../component/CMakeLists.txt) @@ -354,7 +356,7 @@ if(NOT DISABLE_SHARED_LIBS) # to avoid a conflict we rename the import library with the .import.lib suffix set_target_properties(monosgen-shared PROPERTIES IMPORT_SUFFIX ".import.lib") endif() - target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS}) + target_link_libraries(monosgen-shared PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) set_property(TARGET monosgen-shared APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}") endif() @@ -404,7 +406,7 @@ if(NOT DISABLE_SHARED_LIBS) add_library(${frameworkconfig} SHARED $) target_compile_definitions(${frameworkconfig} PRIVATE -DMONO_DLL_EXPORT) target_sources(${frameworkconfig} PRIVATE $) - target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS}) + target_link_libraries(${frameworkconfig} PRIVATE ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(ICU_LDFLAGS) set_property(TARGET ${frameworkconfig} APPEND_STRING PROPERTY LINK_FLAGS " ${ICU_LDFLAGS}") endif() @@ -478,7 +480,7 @@ if(NOT DISABLE_EXECUTABLES) if(MONO_CROSS_COMPILE_EXECUTABLE_NAME) set_target_properties(mono-sgen PROPERTIES OUTPUT_NAME mono-aot-cross) endif() - target_link_libraries(mono-sgen PRIVATE monosgen-static ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS}) + target_link_libraries(mono-sgen PRIVATE monosgen-static ${OS_LIBS} ${ICONV_LIB} ${LLVM_LIBS} ${ICU_LIBS} ${Z_LIBS}) if(NOT DISABLE_COMPONENTS AND STATIC_COMPONENTS AND NOT DISABLE_LINK_STATIC_COMPONENTS) # if components are built statically, link them into runtime. target_sources(mono-sgen PRIVATE "${mono-components-objects}") diff --git a/src/mono/mono/profiler/CMakeLists.txt b/src/mono/mono/profiler/CMakeLists.txt index 784ceb0203d3d4..2b06ab374feb45 100644 --- a/src/mono/mono/profiler/CMakeLists.txt +++ b/src/mono/mono/profiler/CMakeLists.txt @@ -22,6 +22,10 @@ if(NOT DISABLE_LIBS) add_library(mono-profiler-log-static STATIC helper.c log.c log-args.c) set_target_properties(mono-profiler-log-static PROPERTIES OUTPUT_NAME mono-profiler-log) install(TARGETS mono-profiler-log-static LIBRARY) + + if(HAVE_SYS_ZLIB) + target_link_libraries(mono-profiler-log z) + endif() endif() add_library(mono-profiler-aot-static STATIC aot.c helper.c)