Skip to content

Commit 7b1c210

Browse files
committed
Remove FetchContent from compiler build.
1 parent 7712845 commit 7b1c210

7 files changed

Lines changed: 19 additions & 124 deletions

File tree

CMakeLists.txt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,4 @@
11
cmake_minimum_required(VERSION 3.28)
2-
3-
# TODO: remove this after updating build bots.
4-
if (CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg")
5-
if (NOT DEFINED VCPKG_MANIFEST_FEATURES)
6-
set(VCPKG_MANIFEST_FEATURES developer)
7-
endif ()
8-
9-
# vcpkg and FetchContent are incompatible
10-
set(Halide_USE_FETCHCONTENT OFF)
11-
endif ()
12-
13-
option(Halide_USE_FETCHCONTENT "When Halide is top-level, use FetchContent for build-time dependencies." ON)
14-
if (Halide_USE_FETCHCONTENT)
15-
list(APPEND CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies.cmake")
16-
endif ()
17-
182
project(Halide
193
VERSION 22.0.0
204
DESCRIPTION "Halide compiler and libraries"

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
3131
"cacheVariables": {
3232
"VCPKG_MANIFEST_FEATURES": "developer",
33-
"Halide_USE_FETCHCONTENT": false
33+
"FETCHCONTENT_FULLY_DISCONNECTED": "ON"
3434
}
3535
},
3636
{

cmake/dependencies.cmake

Lines changed: 0 additions & 77 deletions
This file was deleted.

doc/BuildingHalideWithCMake.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ necessary, it is convenient to install Python system-wide on Windows (i.e.
230230
`C:\Program Files`) because CMake looks at standard paths and registry keys.
231231
This removes the need to manually set the `PATH`.
232232

233-
Once Python is installed, you can install the Python module dependencies in
233+
Once Python is installed, you can install the Python module dependencies in
234234
a [virtual environment][venv] by running
235235

236236
```shell
@@ -444,12 +444,12 @@ The following options are _advanced_ and should not be required in typical
444444
workflows. Generally, these are used by Halide's own CI infrastructure, or as
445445
escape hatches for third-party packagers.
446446

447-
| Option | Default | Description |
448-
|-----------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------------------------|
449-
| `Halide_CCACHE_BUILD` | `OFF` | Use ccache with Halide-recommended settings to accelerate rebuilds. |
450-
| `Halide_CCACHE_PARAMS` | `CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines` | Options to pass to `ccache` when using `Halide_CCACHE_BUILD`. |
451-
| `Halide_VERSION_OVERRIDE` | `${Halide_VERSION}` | Override the VERSION for libHalide. |
452-
| `Halide_SOVERSION_OVERRIDE` | `${Halide_VERSION_MAJOR}` | Override the SOVERSION for libHalide. Expects a positive integer (i.e. not a version). |
447+
| Option | Default | Description |
448+
|-----------------------------|--------------------------------------------------------------------|----------------------------------------------------------------------------------------|
449+
| `Halide_CCACHE_BUILD` | `OFF` | Use ccache with Halide-recommended settings to accelerate rebuilds. |
450+
| `Halide_CCACHE_PARAMS` | `CCACHE_CPP2=yes CCACHE_HASHDIR=yes CCACHE_SLOPPINESS=pch_defines` | Options to pass to `ccache` when using `Halide_CCACHE_BUILD`. |
451+
| `Halide_VERSION_OVERRIDE` | `${Halide_VERSION}` | Override the VERSION for libHalide. |
452+
| `Halide_SOVERSION_OVERRIDE` | `${Halide_VERSION_MAJOR}` | Override the SOVERSION for libHalide. Expects a positive integer (i.e. not a version). |
453453

454454
The following options control whether to build certain test subsets. They only
455455
apply when `WITH_TESTS=ON`:
@@ -501,10 +501,9 @@ install it into the currently active Python environment.
501501

502502
However, this comes with a few caveats:
503503

504-
1. `Halide_USE_FETCHCONTENT` is disabled, so the environment must be prepared
505-
for CMake to find its dependencies. This is easiest to do by setting either
506-
`CMAKE_PREFIX_PATH` to pre-built dependencies or by setting
507-
`CMAKE_TOOLCHAIN_FILE` to vcpkg.
504+
1. The environment must be prepared for CMake to find its dependencies. This is
505+
easiest to do by setting either `CMAKE_PREFIX_PATH` to pre-built dependencies
506+
or by setting `CMAKE_TOOLCHAIN_FILE` to vcpkg.
508507
2. The build settings are fixed, meaning that `wabt` is required on non-Windows
509508
systems, `flatbuffers` is always required, and the Python bindings must be
510509
built.
@@ -577,8 +576,8 @@ Local storage:
577576
Misses: 0 / 1079 ( 0.00%)
578577
```
579578

580-
On this test system (an M3 MacBook Pro), the build is three times faster,
581-
with a 100% cache hit rate!
579+
On this test system (an M3 MacBook Pro), the build is three times faster, with a
580+
100% cache hit rate!
582581

583582
[ATLAS]: http://math-atlas.sourceforge.net/
584583

doc/CodeStyleCMake.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,14 @@ There are also several functions that are disallowed for other reasons:
137137
| `include_external_msproject` | Halide must remain portable | Write a CMake package config file or find module. |
138138
| `include_guard` | Use of recursive inclusion is not allowed | Write (recursive) functions. |
139139
| `include_regular_expression` | Changes default dependency checking behavior | None |
140-
| `load_cache` | Superseded by [`FetchContent`][FetchContent]/[`ExternalProject`][ExternalProject] | Use aforementioned modules |
140+
| `load_cache` | Superseded by [`FetchContent`][FetchContent]/[`ExternalProject`][ExternalProject] | Write a vcpkg port or present a case for an exception. |
141141
| `macro` | CMake macros are not hygienic and are therefore error-prone | Use functions instead. |
142142
| `site_name` | Privacy: do not want leak host name information | Provide a cache variable, generate a unique name. |
143143
| `variable_watch` | Debugging helper | None. Not needed in production. |
144144

145145
Do not introduce any dependencies via [`find_package`][find_package]
146-
without broader approval. Importantly, never introduce a new use of
147-
`FetchContent`; prefer to add dependencies to `vcpkg.json`.
146+
without broader approval. Importantly, never introduce a use of `FetchContent`.
147+
Add dependencies to `vcpkg.json` or create a custom port.
148148

149149
## Prohibited variables list
150150

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
109109
[tool.scikit-build.cmake.define]
110110
CMAKE_DISABLE_FIND_PACKAGE_JPEG = true
111111
CMAKE_DISABLE_FIND_PACKAGE_PNG = true
112+
FETCHCONTENT_FULLY_DISCONNECTED = true
112113
Halide_ENABLE_EXCEPTIONS = true
113114
Halide_ENABLE_RTTI = true
114115
Halide_INSTALL_PYTHONDIR = "."
115-
Halide_USE_FETCHCONTENT = false
116116
Halide_WASM_BACKEND = "wabt"
117117
WITH_PYTHON_BINDINGS = true
118118
WITH_TESTS = false

src/CMakeLists.txt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -530,12 +530,7 @@ if (WITH_SERIALIZATION)
530530
)
531531
_Halide_pkgdep(flatbuffers)
532532

533-
if (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS)
534-
target_sources(Halide PRIVATE "$<TARGET_OBJECTS:flatbuffers::flatbuffers>")
535-
target_link_libraries(Halide PRIVATE "$<BUILD_LOCAL_INTERFACE:$<COMPILE_ONLY:flatbuffers::flatbuffers>>")
536-
else ()
537-
target_link_libraries(Halide PRIVATE flatbuffers::flatbuffers)
538-
endif ()
533+
target_link_libraries(Halide PRIVATE flatbuffers::flatbuffers)
539534

540535
set(fb_def "${CMAKE_CURRENT_SOURCE_DIR}/halide_ir.fbs")
541536
set(fb_dir "${Halide_BINARY_DIR}/include/flatc")
@@ -591,13 +586,7 @@ if (Halide_WASM_BACKEND STREQUAL "wabt")
591586
find_package(wabt 1.0.39 REQUIRED)
592587
_Halide_pkgdep(wabt)
593588

594-
if (Halide_USE_FETCHCONTENT AND NOT BUILD_SHARED_LIBS)
595-
target_sources(Halide PRIVATE "$<TARGET_OBJECTS:wabt::wabt>")
596-
target_link_libraries(Halide PRIVATE "$<BUILD_LOCAL_INTERFACE:$<COMPILE_ONLY:wabt::wabt>>")
597-
else ()
598-
target_link_libraries(Halide PRIVATE wabt::wabt)
599-
endif ()
600-
589+
target_link_libraries(Halide PRIVATE wabt::wabt)
601590
target_compile_definitions(Halide PRIVATE WITH_WABT)
602591
elseif (Halide_WASM_BACKEND STREQUAL "V8")
603592
find_package(V8 REQUIRED)

0 commit comments

Comments
 (0)