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

formula: trap CMake FetchContent usage instead of using FETCHCONTENT_FULLY_DISCONNECTED #17310

Merged
merged 1 commit into from
May 18, 2024

Conversation

alebcay
Copy link
Member

@alebcay alebcay commented May 16, 2024

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

Follow-up to #17075. With this change, when a formula attempts to use FetchContent_MakeAvailable, the following error is presented:

-- Configuring built-in curl...
CMake Error at /opt/homebrew/Library/Homebrew/trap_fetchcontent_provider.cmake:4 (message):
  Refusing to populate dependency 'zlib' with FetchContent while building in
  Homebrew, please add the dependency as a dependency or resource in the
  formula
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.29.3/share/cmake/Modules/FetchContent.cmake:2017:EVAL:1 (trap_fetchcontent_provider)
  /opt/homebrew/Cellar/cmake/3.29.3/share/cmake/Modules/FetchContent.cmake:2017 (cmake_language)
  cmake/zlib_external.cmake:15 (FetchContent_MakeAvailable)
  CMakeLists.txt:214 (include)


-- Configuring incomplete, errors occurred!

(This is using a modified version of the cpr formula to try the scenario where FetchContent_MakeAvailable gets used; normally this formula will rely on brewed dependencies.)

Formulae can opt out by adding flag -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES= (essentially unsetting the variable). Maybe we can provide something less unwieldy/better named to accomplish this.

Seeking feedback especially about:

  • The error message and what end users or formula authors can do about it
  • Name and location of the .cmake file - for now I just dropped it in HOMEBREW_LIBRARY_PATH, maybe it makes sense to be in some subdirectory, or in the Cellar somewhere (include this file in the cmake formula/bottle rather than as part of brew)

@MikeMcQuaid
Copy link
Member

Formulae can opt out by adding flag -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES= (essentially unsetting the variable). Maybe we can provide something less unwieldy/better named to accomplish this.

Yeh, ideally there'd be a dedicated CMake variable for this -DHOMEBREW_ALLOW_FETCHCONTENT or something?

  • The error message and what end users or formula authors can do about it

I think it's great!

@alebcay alebcay force-pushed the trap-fetchcontent-provider branch from 05fcc60 to 8e7bdbe Compare May 16, 2024 05:45
@alebcay
Copy link
Member Author

alebcay commented May 16, 2024

  • Moved .cmake file into cmake subdirectory
  • Added HOMEBREW_ALLOW_FETCHCONTENT option, which can be set to ON to bypass this
  • Adjusted message text

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Yeh, this looks perfect, thanks again @alebcay!

@alebcay alebcay force-pushed the trap-fetchcontent-provider branch from 8e7bdbe to 7158fc7 Compare May 17, 2024 15:55
@alebcay
Copy link
Member Author

alebcay commented May 17, 2024

Adjusted the scope of the conditional - we probably should just avoid creating the dependency provider altogether if we want to bypass.

@alebcay alebcay force-pushed the trap-fetchcontent-provider branch from 7158fc7 to 920364c Compare May 17, 2024 18:41
Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

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

Looks good, thanks again @alebcay!

@MikeMcQuaid MikeMcQuaid merged commit a5139bb into Homebrew:master May 18, 2024
25 checks passed
@github-actions github-actions bot added the outdated PR was locked due to age label Jun 18, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants