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

Upgrade CMake to 3.24 and refactor FetchContent usage #7794

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
cmake_minimum_required(VERSION 3.22...3.23)
cmake_minimum_required(VERSION 3.24)

# Use our dependency provider by default, but make it easy to
# override

if (NOT DEFINED CMAKE_PROJECT_TOP_LEVEL_INCLUDES)
set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_CURRENT_LIST_DIR}/cmake/dependencies.cmake")
endif ()

project(Halide
VERSION 17.0.0
DESCRIPTION "Halide compiler and libraries"
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ If you wish to build Halide in a separate directory, you can do that like so:

# Building Halide with CMake

Halide requires CMake 3.24 or newer. For guidance on installing a recent CMake
version, please see [README_cmake.md](./README_cmake.md#installing-cmake).

### MacOS and Linux

Follow the above instructions to build LLVM or acquire a suitable binary
Expand Down
45 changes: 20 additions & 25 deletions README_cmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ we strongly suggest reading through the [CMake documentation][cmake-docs] first.

## Installing CMake

Halide requires at least version 3.22, which was released in November 2021.
Fortunately, getting a recent version of CMake couldn't be easier, and there are
multiple good options on any system to do so. Generally, one should always have
the most recent version of CMake installed system-wide. CMake is committed to
backwards compatibility and even the most recent release can build projects over
a decade old.
Halide requires at least version 3.24. Fortunately, getting a recent version of
CMake is easy, and there are multiple good options on any system to do so.
Generally, one should always have the most recent version of CMake installed
system-wide. CMake is committed to backwards compatibility and even the most
recent release can build projects over a decade old.

### Cross-platform

Expand All @@ -90,13 +89,14 @@ See the [PyPI website][pypi-cmake] for more details.

On Windows, there are three primary methods for installing an up-to-date CMake:

1. If you have Visual Studio 2019 installed, you can get CMake 3.17 through the
Visual Studio installer. This is the recommended way of getting CMake if you
are able to use Visual Studio 2019. See Microsoft's
[documentation][vs2019-cmake-docs] for more details.
2. If you use [Chocolatey][chocolatey], its [CMake package][choco-cmake] is kept
1. If you have Visual Studio installed, you can get a recent CMake version through
the Visual Studio installer. This is the recommended way of getting CMake if you
are able to use Visual Studio 2019. See Microsoft's [documentation][vs2019-cmake-docs]
for more details.
2. On Windows 11 and newer, `winget install cmake` should work out of the box.
3. If you use [Chocolatey][chocolatey], its [CMake package][choco-cmake] is kept
up to date. It should be as simple as `choco install cmake`.
3. Otherwise, you should install CMake from [Kitware's website][cmake-download].
4. Otherwise, you should install CMake from [Kitware's website][cmake-download].

### macOS

Expand All @@ -116,18 +116,13 @@ is also a viable option.

There are a few good ways to install a modern CMake on Ubuntu:

1. If you're on Ubuntu Linux 22.04 (Jammy Jellyfish), then simply running
`sudo apt install cmake` will get you CMake 3.22.
2. If you are on an older Ubuntu release or would like to use the newest CMake,
try installing via the snap store: `snap install cmake`. Be sure you do not
already have `cmake` installed via APT. The snap package automatically stays
up to date.
3. For older versions of Debian, Ubuntu, Mint, and derivatives, Kitware provides
an [APT repository][cmake-apt] with up-to-date releases. Note that this is
still useful for Ubuntu 20.04 because it will remain up to date.
4. If all else fails, you might need to build CMake from source (eg. on old
Ubuntu versions running on ARM). In that case, follow the directions posted
on [Kitware's website][cmake-from-source].
1. On any Ubuntu release, you can get the newest CMake via the snap
store: `snap install cmake`. Be sure you do not already have `cmake` installed
via APT. The snap package automatically stays up to date.
2. If you do not wish to use Snap, Kitware provides an [APT repository][cmake-apt]
with up-to-date releases. Compatible with Debian, Ubuntu, Mint, and derivatives.
3. If all else fails, you might need to build CMake from source. In that case,
follow the directions posted on [Kitware's website][cmake-from-source].

For other Linux distributions, check with your distribution's package manager or
use pip as detailed above. Snap packages might also be available.
Expand Down Expand Up @@ -575,7 +570,7 @@ No matter how you intend to use Halide, you will need some basic CMake
boilerplate.

```cmake
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(HalideExample)

set(CMAKE_CXX_STANDARD 17) # or newer
Expand Down
2 changes: 1 addition & 1 deletion apps/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Test apps from the perspective of a consuming project.
##

cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(Halide_apps)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/HelloBaremetal/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

project(HelloBaremetal)

Expand Down
2 changes: 1 addition & 1 deletion apps/HelloBaremetal/cmake-external_project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

# Enable assembly language (.s) support additionally
project(HelloBaremetal LANGUAGES C CXX ASM)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

project(HelloBaremetal-gen)

Expand Down
2 changes: 1 addition & 1 deletion apps/HelloBaremetal/cmake-super_build/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

project(HelloBaremetal-Super)

Expand Down
2 changes: 1 addition & 1 deletion apps/HelloBaremetal/cmake-super_build/app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

# Enable assembly language (.s) support additionally
project(HelloBaremetal-app LANGUAGES C CXX ASM)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

project(HelloBaremetal-gen)

Expand Down
2 changes: 1 addition & 1 deletion apps/HelloBaremetal/cmake-twice/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

# Enable assembly language (.s) support additionally
project(HelloBaremetal LANGUAGES C CXX ASM)
Expand Down
2 changes: 1 addition & 1 deletion apps/HelloWasm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(HelloWasm)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/bgu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(bgu)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/bilateral_grid/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(bilateral_grid)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/blur/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(blur)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/c_backend/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(c_backend)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/camera_pipe/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(camera_pipe)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/compositing/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(compositing)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/conv_layer/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(conv_layer)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/cuda_mat_mul/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(cuda_mat_mul)

# This just checks whether CUDA is available ahead of time to allow
Expand Down
2 changes: 1 addition & 1 deletion apps/depthwise_separable_conv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(depthwise_separable_conv)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/fft/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(fft)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/hannk/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(hannk)

# We need to set this for some of the subprojects pulled in by TFLite (eg flatbuffers)
Expand Down
2 changes: 1 addition & 1 deletion apps/hannk/cmake/superbuild/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22...3.23)
cmake_minimum_required(VERSION 3.24)
project(hannk_superbuild LANGUAGES NONE)

##
Expand Down
2 changes: 1 addition & 1 deletion apps/harris/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(harris)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/hist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(hist)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/iir_blur/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(iir_blur)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/interpolate/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(interpolate)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/lens_blur/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(lens_blur)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/linear_algebra/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(linear_algebra)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/local_laplacian/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(local_laplacian)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/max_filter/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(max_filter)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/nl_means/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(nl_means)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/resize/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(resize)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/stencil_chain/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(stencil_chain)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/unsharp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(unsharp)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion apps/wavelet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)
project(wavelet)

enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion cmake/BundleStatic.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

##
# This module provides a utility for bundling a set of IMPORTED
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindHalide_WebGPU.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

# tip: uncomment this line to get better debugging information if find_library() fails
# set(CMAKE_FIND_DEBUG_MODE TRUE)
Expand Down
2 changes: 1 addition & 1 deletion cmake/HalideGeneratorHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

option(Halide_NO_DEFAULT_FLAGS "When enabled, suppresses recommended flags in add_halide_generator" OFF)

Expand Down
2 changes: 1 addition & 1 deletion cmake/HalideTargetHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

##
# Utilities for manipulating Halide target triples
Expand Down
2 changes: 1 addition & 1 deletion cmake/TargetExportScript.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.22)
cmake_minimum_required(VERSION 3.24)

include(CheckLinkerFlag)

Expand Down