Skip to content

Commit

Permalink
CMake: Rename FindZSTD to FindWrapZSTD
Browse files Browse the repository at this point in the history
And the target ZSTD::ZSTD to WrapZSTD::WrapZSTD.
This should allow building Qt with the
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON set.

Pick-to: 6.2 6.3
Fixes: QTBUG-100537
Change-Id: I748601e4ad6f518323bf1034d6fc1de582c815e1
Reviewed-by: Qt CI Bot <[email protected]>
Reviewed-by: Jörg Bornemann <[email protected]>
  • Loading branch information
alcroito committed Feb 28, 2022
1 parent 0ada264 commit 34a4fe0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
34 changes: 18 additions & 16 deletions cmake/FindZSTD.cmake → cmake/FindWrapZSTD.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@
# Try to locate the Zstd library.
# If found, this will define the following variables:
#
# ``ZSTD_FOUND``
# ``WrapZSTD_FOUND``
# True if the zstd library is available
# ``ZSTD_INCLUDE_DIRS``
# The zstd include directories
# ``ZSTD_LIBRARIES``
# The zstd libraries for linking
#
# If ``ZSTD_FOUND`` is TRUE, it will also define the following
# If ``WrapZSTD_FOUND`` is TRUE, it will also define the following
# imported target:
#
# ``ZSTD::ZSTD``
# ``WrapZSTD::WrapZSTD``
# The zstd library

find_package(zstd CONFIG QUIET)

include(FindPackageHandleStandardArgs)

if(TARGET zstd::libzstd_static OR TARGET zstd::libzstd_shared)
find_package_handle_standard_args(ZSTD REQUIRED_VARS zstd_VERSION VERSION_VAR zstd_VERSION)
find_package_handle_standard_args(WrapZSTD
REQUIRED_VARS zstd_VERSION VERSION_VAR zstd_VERSION)
if(TARGET zstd::libzstd_static)
set(zstdtargetsuffix "_static")
else()
set(zstdtargetsuffix "_shared")
endif()
if(NOT TARGET ZSTD::ZSTD)
add_library(ZSTD::ZSTD INTERFACE IMPORTED)
set_target_properties(ZSTD::ZSTD PROPERTIES
if(NOT TARGET WrapZSTD::WrapZSTD)
add_library(WrapZSTD::WrapZSTD INTERFACE IMPORTED)
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
INTERFACE_LINK_LIBRARIES "zstd::libzstd${zstdtargetsuffix}")
endif()
else()
Expand All @@ -55,29 +56,30 @@ else()
include(SelectLibraryConfigurations)
select_library_configurations(ZSTD)

find_package_handle_standard_args(ZSTD REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS
VERSION_VAR PC_ZSTD_VERSION)
find_package_handle_standard_args(WrapZSTD
REQUIRED_VARS ZSTD_LIBRARIES ZSTD_INCLUDE_DIRS
VERSION_VAR PC_ZSTD_VERSION)

if(ZSTD_FOUND AND NOT TARGET ZSTD::ZSTD)
add_library(ZSTD::ZSTD UNKNOWN IMPORTED)
set_target_properties(ZSTD::ZSTD PROPERTIES
if(WrapZSTD_FOUND AND NOT TARGET WrapZSTD::WrapZSTD)
add_library(WrapZSTD::WrapZSTD UNKNOWN IMPORTED)
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${ZSTD_INCLUDE_DIRS}")
set_target_properties(ZSTD::ZSTD PROPERTIES
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
IMPORTED_LOCATION "${ZSTD_LIBRARY}")
if(ZSTD_LIBRARY_RELEASE)
set_target_properties(ZSTD::ZSTD PROPERTIES
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
IMPORTED_LOCATION_RELEASE "${ZSTD_LIBRARY_RELEASE}")
endif()
if(ZSTD_LIBRARY_DEBUG)
set_target_properties(ZSTD::ZSTD PROPERTIES
set_target_properties(WrapZSTD::WrapZSTD PROPERTIES
IMPORTED_LOCATION_DEBUG "${ZSTD_LIBRARY_DEBUG}")
endif()
endif()

mark_as_advanced(ZSTD_INCLUDE_DIRS ZSTD_LIBRARIES ZSTD_LIBRARY_RELEASE ZSTD_LIBRARY_DEBUG)
endif()
include(FeatureSummary)
set_package_properties(ZSTD PROPERTIES
set_package_properties(WrapZSTD PROPERTIES
URL "https://github.com/facebook/zstd"
DESCRIPTION "ZSTD compression library")

4 changes: 2 additions & 2 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if(TARGET ZLIB::ZLIB)
endif()

# special case end
qt_find_package(ZSTD 1.3 PROVIDED_TARGETS ZSTD::ZSTD MODULE_NAME global QMAKE_LIB zstd)
qt_find_package(WrapZSTD 1.3 PROVIDED_TARGETS WrapZSTD::WrapZSTD MODULE_NAME global QMAKE_LIB zstd)
qt_find_package(WrapDBus1 1.2 PROVIDED_TARGETS dbus-1 MODULE_NAME global QMAKE_LIB dbus)
qt_find_package(Libudev PROVIDED_TARGETS PkgConfig::Libudev MODULE_NAME global QMAKE_LIB libudev)

Expand Down Expand Up @@ -883,7 +883,7 @@ qt_feature("system-zlib" PRIVATE
)
qt_feature("zstd" PRIVATE
LABEL "Zstandard support"
CONDITION ZSTD_FOUND
CONDITION WrapZSTD_FOUND
)
qt_feature("stdlib-libcpp" PRIVATE
LABEL "Using stdlib=libc++"
Expand Down
2 changes: 1 addition & 1 deletion src/corelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ qt_internal_extend_target(Core CONDITION QT_FEATURE_datetimeparser

qt_internal_extend_target(Core CONDITION QT_FEATURE_zstd
LIBRARIES
ZSTD::ZSTD
WrapZSTD::WrapZSTD
)

qt_internal_extend_target(Core CONDITION QT_FEATURE_filesystemwatcher
Expand Down
2 changes: 1 addition & 1 deletion src/network/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ qt_internal_extend_target(Network CONDITION QT_FEATURE_brotli AND QT_FEATURE_htt

qt_internal_extend_target(Network CONDITION QT_FEATURE_http AND QT_FEATURE_zstd
LIBRARIES
ZSTD::ZSTD
WrapZSTD::WrapZSTD
)

qt_internal_extend_target(Network CONDITION QT_FEATURE_system_zlib
Expand Down
2 changes: 1 addition & 1 deletion src/tools/rcc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ qt_internal_extend_target(${target_name} CONDITION QT_FEATURE_zstd AND NOT CMAKE
DEFINES
QT_FEATURE_zstd=1
LIBRARIES
ZSTD::ZSTD
WrapZSTD::WrapZSTD
)

qt_internal_extend_target(${target_name} CONDITION CMAKE_CROSSCOMPILING OR NOT QT_FEATURE_zstd
Expand Down
2 changes: 1 addition & 1 deletion util/cmake/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ def is_qt(self) -> bool:
LibraryMapping("xlib", "X11", "X11::X11"),
LibraryMapping("xrender", "XRender", "PkgConfig::XRender", extra=["0.6"]),
LibraryMapping("zlib", "WrapZLIB", "WrapZLIB::WrapZLIB", extra=["1.0.8"]),
LibraryMapping("zstd", "ZSTD", "ZSTD::ZSTD", extra=["1.3"]),
LibraryMapping("zstd", "WrapZSTD", "WrapZSTD::WrapZSTD", extra=["1.3"]),
LibraryMapping("tiff", "TIFF", "TIFF::TIFF"),
LibraryMapping("webp", "WrapWebP", "WrapWebP::WrapWebP"),
LibraryMapping("jasper", "WrapJasper", "WrapJasper::WrapJasper"),
Expand Down

0 comments on commit 34a4fe0

Please sign in to comment.