From 518e090045c871531cf32d33da06e671517390f8 Mon Sep 17 00:00:00 2001 From: Jacob Su Date: Thu, 22 Apr 2021 15:30:16 +0800 Subject: [PATCH] fix freetype library link error for 7.2 text rendering --- CMakeLists.txt | 4 +++- cmake/modules/FindFreeType2.cmake | 34 +++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 cmake/modules/FindFreeType2.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index a60f028d3..1cfd2f37f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,8 +47,10 @@ elseif(APPLE) FIND_LIBRARY(IOKit_LIBRARY IOKit) FIND_LIBRARY(CoreVideo_LIBRARY CoreVideo) MARK_AS_ADVANCED(COCOA_LIBRARY OpenGL_LIBRARY) + find_package(FreeType2 REQUIRED) + message(STATUS "Found FreeType2 in ${FREETYPE2_INCLUDE_DIR}") SET(APPLE_LIBS ${COCOA_LIBRARY} ${IOKit_LIBRARY} ${OpenGL_LIBRARY} ${CoreVideo_LIBRARY}) - SET(APPLE_LIBS ${APPLE_LIBS} ${GLFW3_LIBRARY} ${ASSIMP_LIBRARY}) + SET(APPLE_LIBS ${APPLE_LIBS} ${GLFW3_LIBRARY} ${ASSIMP_LIBRARY} ${FREETYPE2_LIBRARY}) set(LIBS ${LIBS} ${APPLE_LIBS}) else() set(LIBS ) diff --git a/cmake/modules/FindFreeType2.cmake b/cmake/modules/FindFreeType2.cmake new file mode 100644 index 000000000..61f4f8316 --- /dev/null +++ b/cmake/modules/FindFreeType2.cmake @@ -0,0 +1,34 @@ +# - Try to find FreeType2 +# Once done, this will define +# +# FreeType2_FOUND - system has FreeType2 +# FreeType2_INCLUDE_DIR - the FreeType2 include directories +# FreeType2_LIBRARIES - link these to use FreeType2 +FIND_PATH( FREETYPE2_INCLUDE_DIR freetype2/ft2build.h + /usr/include + /usr/local/include + /opt/local/include + /usr/local/opt/freetype/include + ${CMAKE_SOURCE_DIR}/includes +) +FIND_LIBRARY( FREETYPE2_LIBRARY freetype + /usr/lib64 + /usr/lib + /usr/local/lib + /opt/local/lib + /usr/local/opt/freetype/lib + ${CMAKE_SOURCE_DIR}/lib +) +IF(FREETYPE2_INCLUDE_DIR AND FREETYPE2_LIBRARY) + SET( FREETYPE2_FOUND TRUE ) + SET( FREETYPE2_LIBRARIES ${FREETYPE2_LIBRARY} ) +ENDIF(FREETYPE2_INCLUDE_DIR AND FREETYPE2_LIBRARY) +IF(FREETYPE2_FOUND) + IF(NOT FREETYPE2_FIND_QUIETLY) + MESSAGE(STATUS "Found FREETYPE2: ${FREETYPE2_LIBRARY}") + ENDIF(NOT FREETYPE2_FIND_QUIETLY) +ELSE(FREETYPE2_FOUND) + IF(FREETYPE2_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find libfreetype") + ENDIF(FREETYPE2_FIND_REQUIRED) +ENDIF(FREETYPE2_FOUND)