Skip to content

Commit

Permalink
Merge pull request #17310 from alebcay/trap-fetchcontent-provider
Browse files Browse the repository at this point in the history
formula: trap CMake FetchContent usage instead of using FETCHCONTENT_FULLY_DISCONNECTED
  • Loading branch information
MikeMcQuaid authored May 18, 2024
2 parents b8d844c + 920364c commit a5139bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Library/Homebrew/cmake/trap_fetchcontent_provider.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.24) # Dependency providers introduced in CMake 3.24

option(HOMEBREW_ALLOW_FETCHCONTENT "Allow FetchContent to be used in Homebrew builds" OFF)

if (HOMEBREW_ALLOW_FETCHCONTENT)
return()
endif()

macro(trap_fetchcontent_provider method depName)
message(FATAL_ERROR "Refusing to populate dependency '${depName}' with FetchContent while building in Homebrew, please use a formula dependency or add a resource to the formula.")
endmacro()

cmake_language(
SET_DEPENDENCY_PROVIDER trap_fetchcontent_provider
SUPPORTED_METHODS FETCHCONTENT_MAKEAVAILABLE_SERIAL
)
2 changes: 1 addition & 1 deletion Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1808,7 +1808,7 @@ def std_cmake_args(install_prefix: prefix, install_libdir: "lib", find_framework
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_FIND_FRAMEWORK=#{find_framework}
-DCMAKE_VERBOSE_MAKEFILE=ON
-DFETCHCONTENT_FULLY_DISCONNECTED=ON
-DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=#{HOMEBREW_LIBRARY_PATH}/cmake/trap_fetchcontent_provider.cmake
-Wno-dev
-DBUILD_TESTING=OFF
]
Expand Down

0 comments on commit a5139bb

Please sign in to comment.