Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeType submodule #1446

Merged
merged 4 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
slipher marked this conversation as resolved.
Show resolved Hide resolved
url = https://github.com/DaemonEngine/freetype.git
[submodule "libs/googletest"]
path = libs/googletest
url = https://github.com/DaemonEngine/googletest.git
Expand Down
30 changes: 20 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,8 @@ if ( USE_STATIC_LIBS )
endif()

# zlib
if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP OR (BUILD_CGAME AND NACL AND NOT USE_NACL_SAIGO))
if (NOT NACL)
find_package(ZLIB REQUIRED)
else()
add_library(srclibs-zlib EXCLUDE_FROM_ALL ${ZLIBLIST})
set_target_properties(srclibs-zlib PROPERTIES POSITION_INDEPENDENT_CODE ${GAME_PIE} FOLDER "libs")
set(ZLIB_INCLUDE_DIRS ${LIB_DIR}/zlib)
set(ZLIB_LIBRARIES srclibs-zlib)
endif()
if (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER OR BUILD_DUMMY_APP)
find_package(ZLIB REQUIRED)
set(LIBS_BASE ${LIBS_BASE} ${ZLIB_LIBRARIES})
include_directories(${ZLIB_INCLUDE_DIRS})
endif()
Expand Down Expand Up @@ -791,6 +784,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 +825,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
10 changes: 6 additions & 4 deletions cmake/DaemonFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ else()
if (USE_RECOMMENDED_C_STANDARD)
# GNU89 or later standard is required when building gzip or the compiler
# will complain about implicitly defined lseek, read, write and close.
try_c_flag(GNU89 "-std=gnu89")
if (NOT FLAG_GNU89)
message(FATAL_ERROR "GNU89 or C99 not supported by compiler")
# GNU99 or later standard is required when building lua or lua will
# complain that the compiler doesn't support 'long long'.
try_c_flag(GNU99 "-std=gnu99")
if (NOT FLAG_GNU99)
message(FATAL_ERROR "GNU99 is not supported by the compiler")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test variable's name is now mismatched with the flag

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

endif()
endif()

Expand All @@ -224,7 +226,7 @@ else()
if (NOT FLAG_GNUXX14)
try_cxx_flag(GNUXX1Y "-std=gnu++1y")
if (NOT FLAG_GNUXX1Y)
message(FATAL_ERROR "GNU++14 or C++14 not supported by compiler")
message(FATAL_ERROR "GNU++14 is not supported by the compiler")
endif()
endif()
endif()
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
179 changes: 0 additions & 179 deletions libs/zlib/adler32.c

This file was deleted.

80 changes: 0 additions & 80 deletions libs/zlib/compress.c

This file was deleted.

Loading
Loading