Add Freetype::Freetype target

This commit is contained in:
Chris Thrasher 2023-02-07 23:38:42 -07:00
parent 2c7ed96654
commit fc4a282a64
3 changed files with 15 additions and 14 deletions

View File

@ -143,16 +143,17 @@ if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H)
endforeach()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Freetype DEFAULT_MSG FREETYPE_LIBRARY FREETYPE_INCLUDE_DIRS FREETYPE_VERSION_STRING)
# set FREETYPE_FOUND to TRUE if all listed variables are TRUE
if(FREETYPE_LIBRARY AND FREETYPE_INCLUDE_DIRS AND FREETYPE_VERSION_STRING)
set(FREETYPE_FOUND TRUE)
mark_as_advanced(FREETYPE_LIBRARY FREETYPE_INCLUDE_DIR_freetype2 FREETYPE_INCLUDE_DIR_ft2build)
if(NOT TARGET Freetype::Freetype)
add_library(Freetype::Freetype IMPORTED UNKNOWN)
set_target_properties(Freetype::Freetype PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${FREETYPE_INCLUDE_DIRS}")
if(FREETYPE_LIBRARY MATCHES "/([^/]+)\\.framework$")
set_target_properties(Freetype::Freetype PROPERTIES IMPORTED_LOCATION ${FREETYPE_LIBRARY}/${CMAKE_MATCH_1})
else()
set(FREETYPE_FOUND FALSE)
set_target_properties(Freetype::Freetype PROPERTIES IMPORTED_LOCATION ${FREETYPE_LIBRARY})
endif()
endif()
mark_as_advanced(
FREETYPE_LIBRARY
FREETYPE_INCLUDE_DIR_freetype2
FREETYPE_INCLUDE_DIR_ft2build
)

View File

@ -67,7 +67,7 @@ if(SFML_STATIC_LIBRARIES)
# SFML::Graphics
list(FIND SFML_FIND_COMPONENTS "Graphics" FIND_SFML_GRAPHICS_COMPONENT_INDEX)
if(FIND_SFML_GRAPHICS_COMPONENT_INDEX GREATER -1)
sfml_bind_dependency(TARGET Freetype FRIENDLY_NAME "FreeType" SEARCH_NAMES "freetype")
find_package(Freetype)
endif()
# SFML::Audio

View File

@ -117,8 +117,8 @@ elseif(SFML_OS_IOS)
target_link_libraries(sfml-graphics PRIVATE z bz2)
endif()
sfml_find_package(Freetype FREETYPE_INCLUDE_DIRS FREETYPE_LIBRARY)
target_link_libraries(sfml-graphics PRIVATE Freetype)
find_package(Freetype REQUIRED)
target_link_libraries(sfml-graphics PRIVATE Freetype::Freetype)
# on some platforms (e.g. Raspberry Pi 3 armhf), GCC requires linking libatomic to use <atomic> features
# that aren't supported by native CPU instructions (64-bit atomic operations on 32-bit architecture)