diff options
author | Kai Köhne <kai.koehne@qt.io> | 2022-03-31 12:41:13 +0200 |
---|---|---|
committer | Kai Köhne <kai.koehne@qt.io> | 2022-04-22 14:34:47 +0200 |
commit | 48561178e2488e6fe7763c2229d66072810afcb3 (patch) | |
tree | 4e5347a261a5dcd79d50c982aaf066173c6d5d41 /cmake | |
parent | e3941facca2e365bb2eb961edd7085d081c64220 (diff) |
zlib as static library
Do build zlib as static 3rdparty library. This makes it easier to
disable warnings.
Pick-to: 6.3
Change-Id: I1db331b671b64e68d81c56b0df337983c3bbe7fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/FindWrapSystemZLIB.cmake | 29 | ||||
-rw-r--r-- | cmake/FindWrapZLIB.cmake | 40 |
2 files changed, 40 insertions, 29 deletions
diff --git a/cmake/FindWrapSystemZLIB.cmake b/cmake/FindWrapSystemZLIB.cmake new file mode 100644 index 0000000000..c109a598be --- /dev/null +++ b/cmake/FindWrapSystemZLIB.cmake @@ -0,0 +1,29 @@ +# We can't create the same interface imported target multiple times, CMake will complain if we do +# that. This can happen if the find_package call is done in multiple different subdirectories. +if(TARGET WrapSystemZLIB::WrapSystemZLIB) + set(WrapSystemZLIB_FOUND ON) + return() +endif() + +set(WrapSystemZLIB_FOUND OFF) + +find_package(ZLIB ${${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION}) + +if(ZLIB_FOUND) + set(WrapSystemZLIB_FOUND ON) + + add_library(WrapSystemZLIB::WrapSystemZLIB INTERFACE IMPORTED) + if(APPLE) + # On Darwin platforms FindZLIB sets IMPORTED_LOCATION to the absolute path of the library + # within the framework. This ends up as an absolute path link flag, which we don't want, + # because that makes our .prl files un-relocatable and also breaks iOS simulator_and_device + # SDK switching in Xcode. + # Just pass a linker flag instead. + target_link_libraries(WrapSystemZLIB::WrapSystemZLIB INTERFACE "-lz") + else() + target_link_libraries(WrapSystemZLIB::WrapSystemZLIB INTERFACE ZLIB::ZLIB) + endif() +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WrapSystemZLIB DEFAULT_MSG WrapSystemZLIB_FOUND) diff --git a/cmake/FindWrapZLIB.cmake b/cmake/FindWrapZLIB.cmake index 585dc5e95e..ecb0070f81 100644 --- a/cmake/FindWrapZLIB.cmake +++ b/cmake/FindWrapZLIB.cmake @@ -1,29 +1,11 @@ -# We can't create the same interface imported target multiple times, CMake will complain if we do -# that. This can happen if the find_package call is done in multiple different subdirectories. -if(TARGET WrapZLIB::WrapZLIB) - set(WrapZLIB_FOUND ON) - return() -endif() - -set(WrapZLIB_FOUND OFF) - -find_package(ZLIB ${WrapZLIB_FIND_VERSION}) - -if(ZLIB_FOUND) - set(WrapZLIB_FOUND ON) - - add_library(WrapZLIB::WrapZLIB INTERFACE IMPORTED) - if(APPLE) - # On Darwin platforms FindZLIB sets IMPORTED_LOCATION to the absolute path of the library - # within the framework. This ends up as an absolute path link flag, which we don't want, - # because that makes our .prl files un-relocatable and also breaks iOS simulator_and_device - # SDK switching in Xcode. - # Just pass a linker flag instead. - target_link_libraries(WrapZLIB::WrapZLIB INTERFACE "-lz") - else() - target_link_libraries(WrapZLIB::WrapZLIB INTERFACE ZLIB::ZLIB) - endif() -endif() - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(WrapZLIB DEFAULT_MSG WrapZLIB_FOUND) +include(QtFindWrapHelper NO_POLICY_SCOPE) + +qt_find_package_system_or_bundled(wrap_zlib + FRIENDLY_PACKAGE_NAME "ZLIB" + WRAP_PACKAGE_TARGET "WrapZLIB::WrapZLIB" + WRAP_PACKAGE_FOUND_VAR_NAME "WrapZLIB_FOUND" + BUNDLED_PACKAGE_NAME "BundledZLIB" + BUNDLED_PACKAGE_TARGET "BundledZLIB" + SYSTEM_PACKAGE_NAME "WrapSystemZLIB" + SYSTEM_PACKAGE_TARGET "WrapSystemZLIB::WrapSystemZLIB" +) |