Skip to content

Move handling of Cocoa option after FreeType#21389

Open
vepadulano wants to merge 1 commit intoroot-project:masterfrom
vepadulano:apple-do-not-force-builtin-freetype
Open

Move handling of Cocoa option after FreeType#21389
vepadulano wants to merge 1 commit intoroot-project:masterfrom
vepadulano:apple-do-not-force-builtin-freetype

Conversation

@vepadulano
Copy link
Member

@vepadulano vepadulano commented Feb 26, 2026

When building on Apple with Cocoa graphics, FreeType is required. Previously, there were two separate ways to check for FreeType availability:

  • The "standard" checks for builtins, forcing availability when fail-on-missing is ON, otherwise falling back to activating the builtin if the external package is not found
  • An injected check in the section related to Cocoa, which happened before the section for the builtin, which practically meant that on Apple with Cocoa enabled ROOT was always built with the builtin FreeType library.

This commit proposes to move the section related to Cocoa after the section related to FreeType. This way, the build on Cocoa can only:

  • Fail if FreeType is not found, when fail-on-missing is ON
  • Use the FreeType seen by the rest of the build, the result of the checks in the FreeType section.

As a result, MacOS builds can also now use an externally provided FreeType, useful e.g. for conda-forge builds.

This commit removes the need for the following conda-forge patch: https://github.com/conda-forge/root-feedstock/blob/df86316b299d8214d3181d76c31925696f076d5e/recipe/patches/0009-disable-builtin-freetype-macos.patch

@vepadulano vepadulano requested a review from dpiparo February 26, 2026 09:30
@vepadulano vepadulano self-assigned this Feb 26, 2026
@vepadulano vepadulano requested a review from bellenot as a code owner February 26, 2026 09:30
@vepadulano vepadulano added in:Build System clean build Ask CI to do non-incremental build on PR labels Feb 26, 2026
@vepadulano vepadulano force-pushed the apple-do-not-force-builtin-freetype branch from 018844b to 0faedfd Compare February 26, 2026 09:31
@github-actions
Copy link

github-actions bot commented Feb 26, 2026

Test Results

    22 files      22 suites   3d 2h 57m 33s ⏱️
 3 804 tests  3 801 ✅ 1 💤 2 ❌
75 649 runs  75 638 ✅ 9 💤 2 ❌

For more details on these failures, see this check.

Results for commit 76b795c.

♻️ This comment has been updated with latest results.

@guitargeek
Copy link
Contributor

Great! This change actually shows that the fail-on-missing mechanism was not implemented for the builtin_freetype. Can you maybe add it in this PR, copying some code for other builtins? The idea is that no builtin is implicitly enabled if you set fail-on-missin=ON. The configuration should fail then with an error that tells you which builtin you have to enable.

@vepadulano
Copy link
Member Author

Great! This change actually shows that the fail-on-missing mechanism was not implemented for the builtin_freetype. Can you maybe add it in this PR, copying some code for other builtins? The idea is that no builtin is implicitly enabled if you set fail-on-missin=ON. The configuration should fail then with an error that tells you which builtin you have to enable.

Actually it's even trickier than that! The logic for fail-on-missing for builtin_freetype is implemented at

if(NOT builtin_freetype)
message(STATUS "Looking for Freetype")
if(fail-on-missing)
find_package(Freetype REQUIRED)
else()
find_package(Freetype)
if(FREETYPE_FOUND)
set(FREETYPE_INCLUDE_DIR ${FREETYPE_INCLUDE_DIR_freetype2})
else()
message(STATUS "FreeType not found. Switching on builtin_freetype option")
set(builtin_freetype ON CACHE BOOL "Enabled because FreeType not found (${builtin_freetype_description})" FORCE)
endif()
endif()
endif()
. But then this part of the CMake code completely bypasses that and injects the builtin because it's needed on Apple with Cocoa graphics.

When building on Apple with Cocoa graphics, FreeType is required. Previously, there were two separate ways to check for FreeType availability:

* The "standard" checks for builtins, forcing availability when `fail-on-missing` is ON, otherwise falling back to activating the builtin if the external package is not found
* An injected check in the section related to Cocoa, which happened before the section for the builtin, which practically meant that on Apple with Cocoa enabled ROOT was always built with the builtin FreeType library.

This commit proposes to move the section related to Cocoa after the section related to FreeType. This way, the build on Cocoa can only:

* Fail if FreeType is not found, when `fail-on-missing` is ON
* Use the FreeType seen by the rest of the build, the result of the checks in the FreeType section.

As a result, MacOS builds can also now use an externally provided FreeType, useful e.g. for conda-forge builds.

This commit removes the need for the following conda-forge patch: https://github.com/conda-forge/root-feedstock/blob/df86316b299d8214d3181d76c31925696f076d5e/recipe/patches/0009-disable-builtin-freetype-macos.patch
@vepadulano vepadulano force-pushed the apple-do-not-force-builtin-freetype branch from 0faedfd to 76b795c Compare February 27, 2026 12:15
@vepadulano vepadulano changed the title [build] Allow searching for external FreeType on MacOS Move handling of Cocoa option after FreeType Feb 27, 2026
Copy link
Contributor

@guitargeek guitargeek left a comment

Choose a reason for hiding this comment

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

Thank you very much for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clean build Ask CI to do non-incremental build on PR in:Build System

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants