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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

FreeType submodule #1446

wants to merge 4 commits into from

Conversation

illwieckz
Copy link
Member

@illwieckz illwieckz commented Nov 19, 2024

It is written against the Saigo branch:

There is no submodule yet, one has to clone:

  • https://gitlab.freedesktop.org/freetype/freetype.git as libs/freetype

When USE_SYSTEM_LIBS is set to ON, system libraries are used instead of submodules.

See also:

See this issue for the motivation behind it:

@illwieckz illwieckz force-pushed the illwieckz/submodules/sync branch 6 times, most recently from ee22f48 to f0492fc Compare November 23, 2024 21:37
@illwieckz illwieckz changed the title WIP: freetype submodule FreeType submodule Nov 23, 2024
@illwieckz illwieckz marked this pull request as ready for review November 23, 2024 23:17
@illwieckz illwieckz force-pushed the illwieckz/submodules/sync branch from f0492fc to a50d4e0 Compare December 5, 2024 09:19
@illwieckz illwieckz force-pushed the illwieckz/submodules/sync branch from a50d4e0 to 82553f0 Compare December 18, 2024 00:38
@illwieckz
Copy link
Member Author

If there is no comment about mistakes to fix, I will merge it in two days.

See this comment for the reasons why I want and need FreeType to be a submodule:

@slipher
Copy link
Member

slipher commented Dec 18, 2024

I see that for now, Freetype in the engine would still use the external_deps or system package by default. But what is the future of Freetype in external_deps? Is the plan to remove that and make everyone build it from scratch later?

@illwieckz
Copy link
Member Author

I see that for now, Freetype in the engine would still use the external_deps or system package by default. But what is the future of Freetype in external_deps? Is the plan to remove that and make everyone build it from scratch later?

The plan is to never drop the ability to build against system library. Being able to not rebuild Freetype when the system provides it a wanted feature. This is what classic Linux distributions want. If Debian does an unvanquished.deb, they want it to rely on freetype.deb.

@illwieckz
Copy link
Member Author

illwieckz commented Dec 18, 2024

But we may be able to drop FreeType from external_deps at some point, it's just not on topic of that PR. This PR changes nothing on that side. To drop FreeType from the external deps, extra work is required. That extra work would be to replace USE_SYSTEM_LIBS with PREFER_SYSTEM_LIBS and implement cmake code to only use the submodule as a fallback.

I implemented USE_SYSTEM_LIBS first instead of PREFER_SYSTEM_LIBS to not delay this work because of the extra work being required, but in the end, the delay looks to not be technical.

The future looks like we will be able to drop FreeType from the external_deps entirely while still offering to not rebuild it when the system provides it (Linux, macOS with brew, etc.), but this is not planned for now. Because of the AppVeyor CI being very very slow we may keep this prebuilt for a while for MSVC. I don't know yet what to do.

My priority was to be able to build Lua and FreeType from submodules (required for the static cgame) while not enforcing it and still relying on shared libraries when they exist to not extend the engine build time. The external_deps still counts as system libraries for now.

CMakeLists.txt Outdated
@@ -791,6 +791,8 @@ if (USE_BREAKPAD)
endif()
endif()

option(USE_SYSTEM_LIBS "Tries to use system libs where possible." ON)
Copy link
Member

Choose a reason for hiding this comment

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

This is not a good name since it really means to use any kind of precompiled one. How about inverting the meaning and calling it USE_SOURCE_LIBS? Meaning prefer to build stuff from source.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reverting it may not be a good idea if I change this to some PREFER_SYSTEM_LIBS with a fallback mechanism.

We can name it USE_EXTERNAL_LIBS, that name will fit both the system libraries and the ones from the external_deps folder.

Copy link
Member Author

Choose a reason for hiding this comment

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

I implemented PREFER_EXTERNAL_LIBS instead.

.gitmodules Show resolved Hide resolved
freetype.cmake Outdated
@@ -0,0 +1,18 @@
set(FT_DISABLE_BROTLI ON CACHE STRING "Disable Brotli" FORCE)
Copy link
Member

Choose a reason for hiding this comment

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

If you are adding a new cmake file it should go in cmake/. This is small enough that personally I would just put it in the main file.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why not. I did it that way because I mimicked how rmlui.cmake is stored in Unvanquished repository, but the Unvanquished repository has no cmake/ folder (maybe it's time to do one there too).

Copy link
Member Author

Choose a reason for hiding this comment

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

I will keep it that way for now, to be consistent with all other cmake files in both Unvanquished and Daemon repositories for building sources, like src.cmake, srclibs.cmake (and the lua.cmake and rmlui.cmake ones in Unvanquished).

We can define a new convention later and migrate those to a better name later, but for now this is consistent.

if (NOT FLAG_GNU89)
message(FATAL_ERROR "GNU89 or C99 not supported by compiler")
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.

@illwieckz illwieckz force-pushed the illwieckz/submodules/sync branch 3 times, most recently from 5f97eb4 to e2a9060 Compare December 29, 2024 22:09
@illwieckz
Copy link
Member Author

I implemented PREFER_EXTERNAL_LIBS.

@illwieckz illwieckz force-pushed the illwieckz/submodules/sync branch from e2a9060 to 90f8bb4 Compare December 31, 2024 16:11
CMakeLists.txt Outdated
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 FreeType.")
Copy link
Member

Choose a reason for hiding this comment

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

The library name is hard-coded as "FreeType"

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.

freetype.cmake Outdated
@@ -0,0 +1,18 @@
set(FT_DISABLE_BROTLI ON CACHE STRING "Disable Brotli" FORCE)
set(FT_DISABLE_BZIP2 ON CACHE STRING "Disable bzip2" FORCE)
set(FT_DISABLE_HARFBUZZ ON CACHE STRING "Disable HarfBuzz" FORCE)
Copy link
Member

Choose a reason for hiding this comment

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

The subdirectory stuff showing up in the option list is always annoying. Let's put mark_as_advanced for all those

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. I have also marked as advanced another one we don't modify.

While I was at it, I modified those lines as option(), and we don't force them anymore, we just set the default value we want, and this takes precedence over FreeTypes's own defaults, but still allow us to tweak them if we want.

The only forced FreeType option is FT_DISABLE_ZLIB (option to use builtin FreeType zlib) because it is always ON with NaCl and we already rely on PREFER_EXTERNAL_LIBS instead when building the engine.

@illwieckz illwieckz force-pushed the illwieckz/submodules/sync branch 2 times, most recently from a38a469 to d238ff3 Compare January 4, 2025 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants