Skip to content

Commit

Permalink
libs: make FreeType a submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
illwieckz committed Nov 19, 2024
1 parent 7b21035 commit ff63572
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
[submodule "libs/crunch"]
path = libs/crunch
url = https://github.com/DaemonEngine/crunch.git
[submodule "libs/freetype"]
path = libs/freetype
url = https://github.com/DaemonEngine/freetype.git
[submodule "libs/googletest"]
path = libs/googletest
url = https://github.com/DaemonEngine/googletest.git
Expand Down
19 changes: 18 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,22 @@ if (USE_BREAKPAD)
endif()
endif()

option(PREFER_EXTERNAL_LIBS "Tries to use system libs where possible." ON)

macro(prefer_package LIB_NAME LIB_CMAKE)
if (PREFER_EXTERNAL_LIBS AND NOT NACL)
find_package(${LIB_NAME})

if (NOT ${LIB_NAME}_FOUND)
message(WARNING "PREFER_EXTERNAL_LIBS is enabled but external ${LIB_NAME} is not found, falling back to vendored ${LIB_NAME}.")
endif()
endif()

if (NOT ${LIB_NAME}_FOUND)
include(${LIB_CMAKE})
endif()
endmacro()

if (BUILD_CLIENT)
find_package(Ogg REQUIRED)
include_directories(${OGG_INCLUDE_DIRS})
Expand All @@ -816,7 +832,8 @@ if (BUILD_CLIENT)
include_directories(${PNG_INCLUDE_DIRS})
set(LIBS_CLIENT ${LIBS_CLIENT} ${PNG_LIBRARIES})

find_package(Freetype REQUIRED)
prefer_package(Freetype ${DAEMON_DIR}/freetype.cmake)

include_directories(${FREETYPE_INCLUDE_DIRS})
set(LIBS_CLIENT ${LIBS_CLIENT} ${FREETYPE_LIBRARIES})

Expand Down
25 changes: 25 additions & 0 deletions freetype.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
set(FREETYPE_DIR ${DAEMON_DIR}/libs/freetype)
set(FREETYPE_INCLUDE_DIRS ${FREETYPE_DIR}/include)
set(FREETYPE_LIBRARIES freetype)

option(FT_DISABLE_BROTLI "Disable Brotli" ON)
option(FT_DISABLE_BZIP2 "Disable bzip2" ON)
option(FT_DISABLE_HARFBUZZ "Disable HarfBuzz" ON)
option(FT_DISABLE_PNG "Disable PNG" ON)

if (PREFER_EXTERNAL_LIBS AND NOT NACL)
set(FREETYPE_INTERNAL_ZLIB OFF)
else()
set(FREETYPE_INTERNAL_ZLIB ON)
endif()

set(FT_DISABLE_ZLIB ${FREETYPE_INTERNAL_ZLIB} CACHE BOOL "Disable external zlib" FORCE)

add_subdirectory(${FREETYPE_DIR})

mark_as_advanced(FT_DISABLE_BROTLI)
mark_as_advanced(FT_DISABLE_BZIP2)
mark_as_advanced(FT_DISABLE_HARFBUZZ)
mark_as_advanced(FT_DISABLE_PNG)
mark_as_advanced(FT_DISABLE_ZLIB)
mark_as_advanced(FT_ENABLE_ERROR_STRINGS)
1 change: 1 addition & 0 deletions libs/freetype
Submodule freetype added at 42608f

0 comments on commit ff63572

Please sign in to comment.