diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a916bba26f3..94446b926f84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" diff --git a/README.md b/README.md index a91f9d81911b..5d3181e2ee17 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/README_cmake.md b/README_cmake.md index 49e2f2feb3f7..1a6f54fd3ac0 100644 --- a/README_cmake.md +++ b/README_cmake.md @@ -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 @@ -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 @@ -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. @@ -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 diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 149f6a610b5c..575b5d3e21ba 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -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() diff --git a/apps/HelloBaremetal/CMakeLists.txt b/apps/HelloBaremetal/CMakeLists.txt index 2b8e6bfd5d2a..7362e5ee1db3 100644 --- a/apps/HelloBaremetal/CMakeLists.txt +++ b/apps/HelloBaremetal/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(HelloBaremetal) diff --git a/apps/HelloBaremetal/cmake-external_project/CMakeLists.txt b/apps/HelloBaremetal/cmake-external_project/CMakeLists.txt index fd9e6af3fec0..382bb15466c3 100644 --- a/apps/HelloBaremetal/cmake-external_project/CMakeLists.txt +++ b/apps/HelloBaremetal/cmake-external_project/CMakeLists.txt @@ -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) diff --git a/apps/HelloBaremetal/cmake-external_project/generator/CMakeLists.txt b/apps/HelloBaremetal/cmake-external_project/generator/CMakeLists.txt index ca15a2e44731..990185480bf0 100644 --- a/apps/HelloBaremetal/cmake-external_project/generator/CMakeLists.txt +++ b/apps/HelloBaremetal/cmake-external_project/generator/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(HelloBaremetal-gen) diff --git a/apps/HelloBaremetal/cmake-super_build/CMakeLists.txt b/apps/HelloBaremetal/cmake-super_build/CMakeLists.txt index f863167fc693..7cd0102f22e4 100644 --- a/apps/HelloBaremetal/cmake-super_build/CMakeLists.txt +++ b/apps/HelloBaremetal/cmake-super_build/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(HelloBaremetal-Super) diff --git a/apps/HelloBaremetal/cmake-super_build/app/CMakeLists.txt b/apps/HelloBaremetal/cmake-super_build/app/CMakeLists.txt index 3bbfb32a97c1..00f151cf9dad 100644 --- a/apps/HelloBaremetal/cmake-super_build/app/CMakeLists.txt +++ b/apps/HelloBaremetal/cmake-super_build/app/CMakeLists.txt @@ -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) diff --git a/apps/HelloBaremetal/cmake-super_build/generator/CMakeLists.txt b/apps/HelloBaremetal/cmake-super_build/generator/CMakeLists.txt index a73caef3ad2b..bf1271e969da 100644 --- a/apps/HelloBaremetal/cmake-super_build/generator/CMakeLists.txt +++ b/apps/HelloBaremetal/cmake-super_build/generator/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(HelloBaremetal-gen) diff --git a/apps/HelloBaremetal/cmake-twice/CMakeLists.txt b/apps/HelloBaremetal/cmake-twice/CMakeLists.txt index 2ed355c18766..38f3f5dc2979 100644 --- a/apps/HelloBaremetal/cmake-twice/CMakeLists.txt +++ b/apps/HelloBaremetal/cmake-twice/CMakeLists.txt @@ -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) diff --git a/apps/HelloWasm/CMakeLists.txt b/apps/HelloWasm/CMakeLists.txt index 206639111e84..69fab7fce082 100644 --- a/apps/HelloWasm/CMakeLists.txt +++ b/apps/HelloWasm/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(HelloWasm) enable_testing() diff --git a/apps/bgu/CMakeLists.txt b/apps/bgu/CMakeLists.txt index 0a2f9eb82eec..58c736e4d418 100644 --- a/apps/bgu/CMakeLists.txt +++ b/apps/bgu/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(bgu) enable_testing() diff --git a/apps/bilateral_grid/CMakeLists.txt b/apps/bilateral_grid/CMakeLists.txt index 2b32f0911755..2226df1d6c17 100644 --- a/apps/bilateral_grid/CMakeLists.txt +++ b/apps/bilateral_grid/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(bilateral_grid) enable_testing() diff --git a/apps/blur/CMakeLists.txt b/apps/blur/CMakeLists.txt index f4c3f5324a84..0635fd2864e9 100644 --- a/apps/blur/CMakeLists.txt +++ b/apps/blur/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(blur) enable_testing() diff --git a/apps/c_backend/CMakeLists.txt b/apps/c_backend/CMakeLists.txt index 0d134532dda8..852d9631f2b6 100644 --- a/apps/c_backend/CMakeLists.txt +++ b/apps/c_backend/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(c_backend) enable_testing() diff --git a/apps/camera_pipe/CMakeLists.txt b/apps/camera_pipe/CMakeLists.txt index 0d5a94e26614..d18d4c1d7e20 100644 --- a/apps/camera_pipe/CMakeLists.txt +++ b/apps/camera_pipe/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(camera_pipe) enable_testing() diff --git a/apps/compositing/CMakeLists.txt b/apps/compositing/CMakeLists.txt index f4f7584ce2b9..0c1ea70c202b 100644 --- a/apps/compositing/CMakeLists.txt +++ b/apps/compositing/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(compositing) enable_testing() diff --git a/apps/conv_layer/CMakeLists.txt b/apps/conv_layer/CMakeLists.txt index 94674097d290..071973296316 100644 --- a/apps/conv_layer/CMakeLists.txt +++ b/apps/conv_layer/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(conv_layer) enable_testing() diff --git a/apps/cuda_mat_mul/CMakeLists.txt b/apps/cuda_mat_mul/CMakeLists.txt index 352553ec048b..d13d95c94388 100644 --- a/apps/cuda_mat_mul/CMakeLists.txt +++ b/apps/cuda_mat_mul/CMakeLists.txt @@ -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 diff --git a/apps/depthwise_separable_conv/CMakeLists.txt b/apps/depthwise_separable_conv/CMakeLists.txt index 11e24f335d11..6ef6c0c6d18d 100644 --- a/apps/depthwise_separable_conv/CMakeLists.txt +++ b/apps/depthwise_separable_conv/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(depthwise_separable_conv) enable_testing() diff --git a/apps/fft/CMakeLists.txt b/apps/fft/CMakeLists.txt index 90f099b34bf5..e509675f591c 100644 --- a/apps/fft/CMakeLists.txt +++ b/apps/fft/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(fft) enable_testing() diff --git a/apps/hannk/CMakeLists.txt b/apps/hannk/CMakeLists.txt index 6fabe90f0963..e4f34a109de4 100644 --- a/apps/hannk/CMakeLists.txt +++ b/apps/hannk/CMakeLists.txt @@ -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) diff --git a/apps/hannk/cmake/superbuild/CMakeLists.txt b/apps/hannk/cmake/superbuild/CMakeLists.txt index 1ae17705f3cd..d52f181aad19 100644 --- a/apps/hannk/cmake/superbuild/CMakeLists.txt +++ b/apps/hannk/cmake/superbuild/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22...3.23) +cmake_minimum_required(VERSION 3.24) project(hannk_superbuild LANGUAGES NONE) ## diff --git a/apps/harris/CMakeLists.txt b/apps/harris/CMakeLists.txt index 135129be8752..dffa5ee31c32 100644 --- a/apps/harris/CMakeLists.txt +++ b/apps/harris/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(harris) enable_testing() diff --git a/apps/hist/CMakeLists.txt b/apps/hist/CMakeLists.txt index 7aebca4984ec..def0d3491e17 100644 --- a/apps/hist/CMakeLists.txt +++ b/apps/hist/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(hist) enable_testing() diff --git a/apps/iir_blur/CMakeLists.txt b/apps/iir_blur/CMakeLists.txt index 6e61e7ecd0ee..d44166c9f118 100644 --- a/apps/iir_blur/CMakeLists.txt +++ b/apps/iir_blur/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(iir_blur) enable_testing() diff --git a/apps/interpolate/CMakeLists.txt b/apps/interpolate/CMakeLists.txt index d723ac3b35da..5c851d8afa59 100644 --- a/apps/interpolate/CMakeLists.txt +++ b/apps/interpolate/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(interpolate) enable_testing() diff --git a/apps/lens_blur/CMakeLists.txt b/apps/lens_blur/CMakeLists.txt index dcd9a70e4ac7..b16e0dec5d0d 100644 --- a/apps/lens_blur/CMakeLists.txt +++ b/apps/lens_blur/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(lens_blur) enable_testing() diff --git a/apps/linear_algebra/CMakeLists.txt b/apps/linear_algebra/CMakeLists.txt index adbe63b91df4..84ccd9857500 100644 --- a/apps/linear_algebra/CMakeLists.txt +++ b/apps/linear_algebra/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(linear_algebra) enable_testing() diff --git a/apps/local_laplacian/CMakeLists.txt b/apps/local_laplacian/CMakeLists.txt index 077382da3a77..c5a2311cb869 100644 --- a/apps/local_laplacian/CMakeLists.txt +++ b/apps/local_laplacian/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(local_laplacian) enable_testing() diff --git a/apps/max_filter/CMakeLists.txt b/apps/max_filter/CMakeLists.txt index 68b228438c5f..0f8eadc17f68 100644 --- a/apps/max_filter/CMakeLists.txt +++ b/apps/max_filter/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(max_filter) enable_testing() diff --git a/apps/nl_means/CMakeLists.txt b/apps/nl_means/CMakeLists.txt index a92bedb14a3b..351abc54eb1a 100644 --- a/apps/nl_means/CMakeLists.txt +++ b/apps/nl_means/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(nl_means) enable_testing() diff --git a/apps/resize/CMakeLists.txt b/apps/resize/CMakeLists.txt index 1b5d14233c74..1f0436d13074 100644 --- a/apps/resize/CMakeLists.txt +++ b/apps/resize/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(resize) enable_testing() diff --git a/apps/stencil_chain/CMakeLists.txt b/apps/stencil_chain/CMakeLists.txt index ed85b1ba0c36..25c369c21f8f 100644 --- a/apps/stencil_chain/CMakeLists.txt +++ b/apps/stencil_chain/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(stencil_chain) enable_testing() diff --git a/apps/unsharp/CMakeLists.txt b/apps/unsharp/CMakeLists.txt index 443cf92fb0a3..6f48e0c0d131 100644 --- a/apps/unsharp/CMakeLists.txt +++ b/apps/unsharp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(unsharp) enable_testing() diff --git a/apps/wavelet/CMakeLists.txt b/apps/wavelet/CMakeLists.txt index bd142bcf07c4..f21ae730f322 100644 --- a/apps/wavelet/CMakeLists.txt +++ b/apps/wavelet/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(wavelet) enable_testing() diff --git a/cmake/BundleStatic.cmake b/cmake/BundleStatic.cmake index 023db8edd1f2..1cbf7c7ae2d2 100644 --- a/cmake/BundleStatic.cmake +++ b/cmake/BundleStatic.cmake @@ -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 diff --git a/cmake/FindHalide_WebGPU.cmake b/cmake/FindHalide_WebGPU.cmake index 22a8fc38b326..1885007058a2 100644 --- a/cmake/FindHalide_WebGPU.cmake +++ b/cmake/FindHalide_WebGPU.cmake @@ -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) diff --git a/cmake/HalideGeneratorHelpers.cmake b/cmake/HalideGeneratorHelpers.cmake index f62da88b1f7b..bfd4d14e4d5a 100644 --- a/cmake/HalideGeneratorHelpers.cmake +++ b/cmake/HalideGeneratorHelpers.cmake @@ -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) diff --git a/cmake/HalideTargetHelpers.cmake b/cmake/HalideTargetHelpers.cmake index 78adb705486c..c81ed3508e1b 100644 --- a/cmake/HalideTargetHelpers.cmake +++ b/cmake/HalideTargetHelpers.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) ## # Utilities for manipulating Halide target triples diff --git a/cmake/TargetExportScript.cmake b/cmake/TargetExportScript.cmake index 0e8b427e77fa..1ba26b0cfbf5 100644 --- a/cmake/TargetExportScript.cmake +++ b/cmake/TargetExportScript.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) include(CheckLinkerFlag) diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake new file mode 100644 index 000000000000..0eaacbb1d79c --- /dev/null +++ b/cmake/dependencies.cmake @@ -0,0 +1,72 @@ +cmake_minimum_required(VERSION 3.24) + +include(FetchContent) + +## +# Flatbuffers + +FetchContent_Declare( + flatbuffers + GIT_REPOSITORY https://github.com/google/flatbuffers.git + GIT_TAG 0100f6a5779831fa7a651e4b67ef389a8752bd9b # v23.5.26 + GIT_SHALLOW TRUE + OVERRIDE_FIND_PACKAGE +) + +# Fix up the targets +if (NOT EXISTS "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/flatbuffers-extra.cmake") + file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/flatbuffers-extra.cmake" [=[ +add_executable(flatbuffers::flatc ALIAS flatc) + +add_library(flatbuffers::flatbuffers ALIAS flatbuffers) +if (BUILD_SHARED_LIBS) + set_property(TARGET flatbuffers PROPERTY POSITION_INDEPENDENT_CODE ON) +endif () +]=]) +endif () + +## +# pybind11 + +FetchContent_Declare( + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11.git + GIT_TAG 5b0a6fc2017fcc176545afe3e09c9f9885283242 # v3.10.4 + GIT_SHALLOW TRUE + OVERRIDE_FIND_PACKAGE +) + +## +# wabt + +FetchContent_Declare( + wabt + GIT_REPOSITORY https://github.com/WebAssembly/wabt.git + GIT_TAG 963f973469b45969ce198e0c86d3af316790a780 # 1.0.33 + GIT_SHALLOW TRUE + OVERRIDE_FIND_PACKAGE +) + +# Configure the project for vendored usage +set(CMAKE_PROJECT_WABT_INCLUDE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/wabt-vars.cmake") +if (NOT EXISTS "${CMAKE_PROJECT_WABT_INCLUDE}") + file(WRITE "${CMAKE_PROJECT_WABT_INCLUDE}" [=[ +set(WITH_EXCEPTIONS ${Halide_ENABLE_EXCEPTIONS}) +set(BUILD_TESTS OFF) +set(BUILD_TOOLS OFF) +set(BUILD_LIBWASM OFF) +set(USE_INTERNAL_SHA256 ON) +]=]) +endif () + +# Fix up the targets +if (NOT EXISTS "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/wabt-extra.cmake") + file(WRITE "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR}/wabt-extra.cmake" [=[ +target_compile_options( + wabt PRIVATE $<$:-Wno-alloca-larger-than> +) +if (BUILD_SHARED_LIBS) + set_property(TARGET wabt PROPERTY POSITION_INDEPENDENT_CODE ON) +endif () +]=]) +endif () diff --git a/dependencies/wasm/CMakeLists.txt b/dependencies/wasm/CMakeLists.txt index 7c0a02b377f1..06009f10317f 100644 --- a/dependencies/wasm/CMakeLists.txt +++ b/dependencies/wasm/CMakeLists.txt @@ -1,4 +1,3 @@ -include(FetchContent) include(CMakeDependentOption) cmake_dependent_option(WITH_WABT "Include WABT Interpreter for WASM testing" ON "TARGET_WEBASSEMBLY" OFF) @@ -16,40 +15,7 @@ if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") endif () if (WITH_WABT) - set(WABT_VER 1.0.33) - - message(STATUS "Fetching WABT ${WABT_VER}...") - FetchContent_Declare(wabt - GIT_REPOSITORY https://github.com/WebAssembly/wabt.git - GIT_TAG ${WABT_VER} - GIT_SHALLOW TRUE) - - # configuration for wabt - set(WITH_EXCEPTIONS ${Halide_ENABLE_EXCEPTIONS}) - set(BUILD_TESTS OFF) - set(BUILD_TOOLS OFF) - set(BUILD_LIBWASM OFF) - set(USE_INTERNAL_SHA256 ON) - FetchContent_MakeAvailable(wabt) - - set_target_properties(wabt PROPERTIES POSITION_INDEPENDENT_CODE ON) - - # Disable this very-noisy warning in GCC - target_compile_options(wabt - PRIVATE - $<$:-Wno-alloca-larger-than>) - - # TODO: we want to require unique prefixes to include these files, to avoid ambiguity; - # this means we have to prefix with "wabt-src/...", which is less bad than other alternatives, - # but perhaps we could do better (esp. if wabt was smarter about what it exposed?) - add_library(Halide_wabt INTERFACE) - target_sources(Halide_wabt INTERFACE $>) - target_include_directories(Halide_wabt - SYSTEM # Use -isystem instead of -I; this is a trick so that clang-tidy won't analyze these includes - INTERFACE - $/include - $/include) - set_target_properties(Halide_wabt PROPERTIES EXPORT_NAME wabt) + find_package(wabt 1.0.33 REQUIRED) endif () if (WITH_V8) diff --git a/packaging/common/HalideConfig.cmake b/packaging/common/HalideConfig.cmake index b611aadaf77e..f6c48a38d2c4 100644 --- a/packaging/common/HalideConfig.cmake +++ b/packaging/common/HalideConfig.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) macro(Halide_fail message) set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${message}") diff --git a/packaging/common/HalideHelpersConfig.cmake b/packaging/common/HalideHelpersConfig.cmake index b1801e99c6e6..5216bac2973e 100644 --- a/packaging/common/HalideHelpersConfig.cmake +++ b/packaging/common/HalideHelpersConfig.cmake @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) set(Halide_HOST_TARGET @Halide_HOST_TARGET@) diff --git a/pyproject.toml b/pyproject.toml index b91c918d1d6e..2ff253f2069a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ requires = [ "wheel", "scikit-build", "pybind11==2.10.4", - "cmake>=3.22", + "cmake>=3.24", "ninja; platform_system!='Windows'" ] build-backend = "setuptools.build_meta" diff --git a/python_bindings/CMakeLists.txt b/python_bindings/CMakeLists.txt index 590ecc432e10..2d8869547543 100644 --- a/python_bindings/CMakeLists.txt +++ b/python_bindings/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22...3.23) +cmake_minimum_required(VERSION 3.24) project(Halide_Python) include(CMakeDependentOption) @@ -23,10 +23,6 @@ cmake_dependent_option( WITH_TESTS OFF ) -# Set the expected (downloaded) version of pybind11 -option(PYBIND11_USE_FETCHCONTENT "Enable to download pybind11 via FetchContent" ON) -set(PYBIND11_VER 2.10.4 CACHE STRING "The pybind11 version to use (or download)") - ## # Dependencies ## @@ -35,23 +31,9 @@ set(PYBIND11_VER 2.10.4 CACHE STRING "The pybind11 version to use (or download)" # Development.Module and Development.Embed. We don't need the Embed # part, so only requesting Module avoids failures when Embed is not # available, as is the case in the manylinux Docker images. -find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module) -if (Python3_VERSION VERSION_LESS "3.8") - message(FATAL_ERROR "Halide requires Python v3.8 or later, but found ${Python3_VERSION}.") -endif () -message(STATUS "Found Python ${Python3_VERSION} at ${Python3_EXECUTABLE}") - -if (PYBIND11_USE_FETCHCONTENT) - include(FetchContent) - FetchContent_Declare( - pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11.git - GIT_TAG v${PYBIND11_VER} - ) - FetchContent_MakeAvailable(pybind11) -else () - find_package(pybind11 ${PYBIND11_VER} REQUIRED) -endif () +find_package(Python3 3.8 REQUIRED COMPONENTS Interpreter Development.Module) + +find_package(pybind11 2.10.4 REQUIRED) find_package(Halide REQUIRED Halide) if (NOT Halide_ENABLE_RTTI OR NOT Halide_ENABLE_EXCEPTIONS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1edc296aa775..d3aa9429545e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -419,12 +419,18 @@ add_custom_target(HalideIncludes ALL DEPENDS "${Halide_BINARY_DIR}/include/Halid # Define the Halide library target. ## -add_library(Halide - ${SOURCE_FILES} - ${HEADER_FILES} - # Including these as sources works around the need to "install" Halide_initmod - $ - $) +add_library(Halide) +add_library(Halide::Halide ALIAS Halide) + +target_sources( + Halide + PRIVATE + ${SOURCE_FILES} + ${HEADER_FILES} + # Including these as sources works around the need to "install" Halide_initmod + $ + $ +) ## # Flatbuffers and Serialization dependencies. @@ -433,85 +439,26 @@ add_library(Halide # Build serialization, enabled by default option(WITH_SERIALIZATION "Include experimental Serialization/Deserialization code" ON) -# flatbuffers is small and compiles quickly, but if you want/need to use -# a local version (via find_package), configure with FLATBUFFERS_USE_FETCHCONTENT=OFF -option(FLATBUFFERS_USE_FETCHCONTENT "Enable to download the Flatbuffers library via FetchContent" ON) -set(FLATBUFFERS_VER 23.5.26 CACHE STRING "The Flatbuffers version to use (or download)") - if (WITH_SERIALIZATION) - if (FLATBUFFERS_USE_FETCHCONTENT) - include(FetchContent) - message(STATUS "Fetching flatbuffers ${FLATBUFFERS_VER}...") - FetchContent_Declare( - flatbuffers - GIT_REPOSITORY https://github.com/google/flatbuffers.git - GIT_TAG v${FLATBUFFERS_VER} - GIT_SHALLOW TRUE - ) - # configuration for flatbuffers - set(FLATBUFFERS_BUILD_TESTS OFF) - set(FLATBUFFERS_INSTALL OFF) - FetchContent_MakeAvailable(flatbuffers) - set_target_properties(flatbuffers PROPERTIES POSITION_INDEPENDENT_CODE ON) - - add_library(Halide_flatbuffers INTERFACE) - target_sources(Halide_flatbuffers INTERFACE $>) - target_include_directories(Halide_flatbuffers - SYSTEM # Use -isystem instead of -I; this is a trick so that clang-tidy won't analyze these includes - INTERFACE - $/include - $/include) - set_target_properties(Halide_flatbuffers PROPERTIES EXPORT_NAME flatbuffers) - - add_executable(flatbuffers::flatc ALIAS flatc) - message(STATUS "Using fetched-and-built flatbuffers, version ${FLATBUFFERS_VER}") - else () - # Sadly, there seem to be at least three variations of the Flatbuffer package - # in terms of the case of the relevant CMake files; if we guess wrong, we - # fail on case-sensitive file systems. We'll try this as a hack workaround: - # just try all three. (Note that the internal CMake library name appears to be - # `flatbuffers` in all cases.) - set(FB_NAME "") - foreach (N IN ITEMS flatbuffers Flatbuffers FlatBuffers) - # TODO: should we check the version here? - find_package(${N} QUIET) - if (${N}_FOUND) - set(FB_NAME ${N}) - message(STATUS "Using installed flatbuffers, version ${${N}_VERSION}") - break() - endif () - endforeach () - - if (NOT FB_NAME) - message(FATAL_ERROR "WITH_SERIALIZATION is ON and FLATBUFFERS_USE_FETCHCONTENT is OFF, " - "but could not find flatbuffers installed locally. " - "Either install flatbuffers or build with WITH_SERIALIZATION=OFF.") - endif () - - add_library(Halide_flatbuffers ALIAS flatbuffers::flatbuffers) - endif () - - set(fb_dir "${Halide_BINARY_DIR}/flatc/include") + find_package(flatbuffers 23.5.26 REQUIRED) set(fb_def "${CMAKE_CURRENT_SOURCE_DIR}/halide_ir.fbs") + set(fb_dir "${Halide_BINARY_DIR}/flatc/include") set(fb_header "${fb_dir}/halide_ir_generated.h") + add_custom_command( OUTPUT "${fb_header}" COMMAND flatbuffers::flatc --cpp -o "${fb_dir}" "${fb_def}" DEPENDS "${fb_def}" VERBATIM ) - add_custom_target(generate_fb_header DEPENDS "${fb_header}") - set_source_files_properties("${fb_header}" PROPERTIES GENERATED TRUE) - add_dependencies(Halide generate_fb_header) - target_include_directories(Halide PRIVATE "$") - target_link_libraries(Halide PRIVATE Halide_flatbuffers) target_compile_definitions(Halide PRIVATE WITH_SERIALIZATION) + target_include_directories(Halide PRIVATE "$") + target_link_libraries(Halide PRIVATE flatbuffers::flatbuffers) + target_sources(Halide PRIVATE "${fb_header}") endif () -add_library(Halide::Halide ALIAS Halide) - target_link_libraries(Halide PRIVATE Halide::LLVM) target_link_libraries(Halide PUBLIC Halide::LanguageOptions) target_compile_definitions(Halide PRIVATE $<$,STATIC_LIBRARY>:Halide_STATIC_DEFINE>) diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 600b1d765a36..0675d8d2b69e 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(integration_tests NONE) enable_testing() diff --git a/test/integration/aot/CMakeLists.txt b/test/integration/aot/CMakeLists.txt index b370a642339b..de16dabd4fc9 100644 --- a/test/integration/aot/CMakeLists.txt +++ b/test/integration/aot/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(aot) enable_testing() diff --git a/test/integration/jit/CMakeLists.txt b/test/integration/jit/CMakeLists.txt index a6f24342184a..97cefa78dfe5 100644 --- a/test/integration/jit/CMakeLists.txt +++ b/test/integration/jit/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(jit) enable_testing() diff --git a/test/integration/xc/CMakeLists.txt b/test/integration/xc/CMakeLists.txt index 8552e9cefc62..4579ff87ec53 100644 --- a/test/integration/xc/CMakeLists.txt +++ b/test/integration/xc/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.22) +cmake_minimum_required(VERSION 3.24) project(xc) enable_testing()