Fix external freetype that provides freetype-config.cmake (#35363)

* Fix external freetype that provides freetype-config.cmake

---------

Co-authored-by: Dan Lipsa <dan.lipsa@khq.kitware.com>
This commit is contained in:
Dan Lipsa 2023-02-08 11:00:14 -05:00 committed by GitHub
parent 27c2ff6c64
commit 126accfce1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 0 deletions

View file

@ -0,0 +1,35 @@
diff --git a/VTK/CMake/FindFreetype.cmake b/VTK/CMake/FindFreetype.cmake
index b4532735c2..f06d32327e 100644
--- a/VTK/CMake/FindFreetype.cmake
+++ b/VTK/CMake/FindFreetype.cmake
@@ -63,6 +63,30 @@ directory of a Freetype installation.
# I'm going to attempt to cut out the middleman and hope
# everything still works.
+find_package(freetype CONFIG) # foward `QUIET`, version, and components here, but not `REQUIRED`
+if (freetype_FOUND)
+ if (NOT TARGET Freetype::Freetype)
+ # make target chain to target from config mode
+ get_target_property(freetype_library_type freetype TYPE)
+ get_target_property(freetype_location freetype LOCATION)
+ if (freetype_library_type STREQUAL STATIC_LIBRARY)
+ set(freetype_library_type STATIC)
+ endif()
+ get_target_property(freetype_interface_include_directories freetype INTERFACE_INCLUDE_DIRECTORIES)
+ get_target_property(freetype_interface_link_libraries freetype INTERFACE_LINK_LIBRARIES)
+ add_library(Freetype::Freetype "${freetype_library_type}" IMPORTED)
+ set_target_properties(Freetype::Freetype PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${freetype_interface_include_directories}"
+ INTERFACE_LINK_LIBRARIES "${freetype_interface_link_libraries}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION "${freetype_location}")
+ endif ()
+ set(FREETYPE_INCLUDE_DIRS "${freetype_interface_include_directories}")
+ set(FREETYPE_LIBRARIES "${freetype_interface_link_libraries}")
+ set(Freetype_FOUND 1) # might need to also forward the version found
+ return ()
+endif ()
+
set(FREETYPE_FIND_ARGS
HINTS
ENV FREETYPE_DIR

View file

@ -273,6 +273,9 @@ class Paraview(CMakePackage, CudaPackage, ROCmPackage):
patch("vtk-xdmf2-hdf51.13.1.patch", when="@5.10.0:5.10") patch("vtk-xdmf2-hdf51.13.1.patch", when="@5.10.0:5.10")
patch("vtk-xdmf2-hdf51.13.2.patch", when="@5.10:") patch("vtk-xdmf2-hdf51.13.2.patch", when="@5.10:")
# Fix VTK to work with external freetype using CONFIG mode for find_package
patch("FindFreetype.cmake.patch", when="@5.10.1:")
@property @property
def generator(self): def generator(self):
# https://gitlab.kitware.com/paraview/paraview/-/issues/21223 # https://gitlab.kitware.com/paraview/paraview/-/issues/21223