formula: trap CMake FetchContent usage instead of using FETCHCONTENT_FULLY_DISCONNECTED

This commit is contained in:
Caleb Xu 2024-05-15 19:53:26 -04:00
parent b8d844ced8
commit 920364ca87
No known key found for this signature in database
GPG Key ID: 47E6040D07B8407D
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
]