Fix freetype target not being found when using vcpkg
vcpkg and upstream CMake find module define different target names for the same package. To circumvent this, create our own Wrap find module, and link against it. Inside the find module, try both target names. Change-Id: Iba488bce0fb410ddb83f6414244f86ad367de72b Reviewed-by: Liang Qi <liang.qi@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
parent
e8bb673301
commit
9d96c8da78
26
cmake/FindWrapFreetype.cmake
Normal file
26
cmake/FindWrapFreetype.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
# 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 WrapFreetype::WrapFreetype)
|
||||
set(WrapFreetype_FOUND ON)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(WrapFreetype_FOUND OFF)
|
||||
find_package(Freetype)
|
||||
|
||||
if(Freetype_FOUND)
|
||||
# vcpkg defines a lower case target name, while upstream Find module defines a prefixed
|
||||
# upper case name.
|
||||
set(potential_target_names Freetype::Freetype freetype)
|
||||
foreach(target_name ${potential_target_names})
|
||||
if(TARGET ${target_name})
|
||||
set(WrapFreetype_FOUND ON)
|
||||
set(final_target_name ${target_name})
|
||||
|
||||
add_library(WrapFreetype::WrapFreetype INTERFACE IMPORTED)
|
||||
target_link_libraries(WrapFreetype::WrapFreetype INTERFACE ${final_target_name})
|
||||
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
@ -25,8 +25,8 @@ set_property(CACHE INPUT_xcb PROPERTY STRINGS undefined no yes qt system)
|
||||
qt_find_package(ATSPI2 PROVIDED_TARGETS PkgConfig::ATSPI2)
|
||||
qt_find_package(Libdrm PROVIDED_TARGETS Libdrm::Libdrm)
|
||||
qt_find_package(EGL PROVIDED_TARGETS EGL::EGL)
|
||||
qt_find_package(Freetype PROVIDED_TARGETS Freetype::Freetype)
|
||||
set_package_properties(Freetype PROPERTIES TYPE REQUIRED)
|
||||
qt_find_package(WrapFreetype PROVIDED_TARGETS WrapFreetype::WrapFreetype)
|
||||
set_package_properties(WrapFreetype::WrapFreetype PROPERTIES TYPE REQUIRED)
|
||||
qt_find_package(Fontconfig PROVIDED_TARGETS Fontconfig::Fontconfig)
|
||||
qt_find_package(gbm PROVIDED_TARGETS gbm::gbm)
|
||||
qt_find_package(harfbuzz PROVIDED_TARGETS harfbuzz::harfbuzz)
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Generated from fontdatabases.pro.
|
||||
|
||||
qt_find_package(Freetype) # special case
|
||||
qt_find_package(WrapFreetype) # special case
|
||||
qt_find_package(Fontconfig) # special case
|
||||
|
||||
#####################################################################
|
||||
@ -54,7 +54,7 @@ extend_target(FontDatabaseSupport CONDITION QT_FEATURE_freetype
|
||||
freetype/qfontengine_ft.cpp freetype/qfontengine_ft_p.h
|
||||
freetype/qfreetypefontdatabase.cpp freetype/qfreetypefontdatabase_p.h
|
||||
LIBRARIES
|
||||
Freetype::Freetype
|
||||
WrapFreetype::WrapFreetype
|
||||
)
|
||||
|
||||
extend_target(FontDatabaseSupport CONDITION UNIX
|
||||
|
@ -1,4 +1,4 @@
|
||||
qt_find_package(Freetype) # special case
|
||||
qt_find_package(WrapFreetype) # special case
|
||||
|
||||
#####################################################################
|
||||
## qminimal Plugin:
|
||||
@ -29,7 +29,7 @@ add_qt_plugin(qminimal
|
||||
|
||||
extend_target(qminimal CONDITION QT_FEATURE_freetype
|
||||
LIBRARIES
|
||||
Freetype::Freetype
|
||||
WrapFreetype::WrapFreetype
|
||||
)
|
||||
|
||||
#### Keys ignored in scope 3:.:minimal.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN:
|
||||
|
@ -6,7 +6,7 @@ qt_find_package(X11)
|
||||
qt_find_package(XCB)
|
||||
qt_find_package(XKB)
|
||||
qt_find_package(PkgConfig)
|
||||
qt_find_package(Freetype)
|
||||
qt_find_package(WrapFreetype)
|
||||
qt_find_package(GLIB2)
|
||||
|
||||
pkg_check_modules(XKB_COMMON_X11 xkbcommon-x11>=0.4.1 IMPORTED_TARGET) # special case
|
||||
@ -165,7 +165,7 @@ extend_target(XcbQpa CONDITION QT_FEATURE_xcb_native_painting AND QT_FEATURE_xre
|
||||
|
||||
extend_target(XcbQpa CONDITION QT_FEATURE_fontconfig AND QT_FEATURE_xcb_native_painting
|
||||
LIBRARIES
|
||||
Freetype::Freetype
|
||||
WrapFreetype::WrapFreetype
|
||||
)
|
||||
#####################################################################
|
||||
## qxcb Plugin:
|
||||
|
@ -181,7 +181,7 @@ _library_map = [
|
||||
LibraryMapping('drm', 'Libdrm', 'Libdrm::Libdrm'),
|
||||
LibraryMapping('egl', 'EGL', 'EGL::EGL'),
|
||||
LibraryMapping('fontconfig', 'Fontconfig', 'Fontconfig::Fontconfig', resultVariable="FONTCONFIG"),
|
||||
LibraryMapping('freetype', 'Freetype', 'Freetype::Freetype', extra=['REQUIRED']),
|
||||
LibraryMapping('freetype', 'WrapFreetype', 'WrapFreetype::WrapFreetype', extra=['REQUIRED']),
|
||||
LibraryMapping('gbm', 'gbm', 'gbm::gbm'),
|
||||
LibraryMapping('glib', 'GLIB2', 'GLIB2::GLIB2'),
|
||||
LibraryMapping('gnu_iconv', None, None),
|
||||
|
Loading…
x
Reference in New Issue
Block a user