Merge pull request #17310 from alebcay/trap-fetchcontent-provider

formula: trap CMake FetchContent usage instead of using FETCHCONTENT_FULLY_DISCONNECTED
This commit is contained in:
Mike McQuaid 2024-05-18 07:28:13 +01:00 committed by GitHub
commit a5139bb8e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 1 deletions

View File

@ -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
)

View File

@ -1808,7 +1808,7 @@ class Formula
-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
]