11cmake_minimum_required (VERSION 3.28 )
2- project (Halide
3- VERSION 22.0.0
4- DESCRIPTION "Halide compiler and libraries"
5- HOMEPAGE_URL "https://halide-lang.org" )
2+ project (
3+ Halide
4+ VERSION 22.0.0
5+ DESCRIPTION "Halide compiler and libraries"
6+ HOMEPAGE_URL "https://halide-lang.org"
7+ )
68
79enable_testing ()
810
911##
1012# Disable find_package(Halide) inside the build
1113##
1214
13- file (CONFIGURE OUTPUT "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR} /HalideConfig.cmake"
14- CONTENT [[ set(Halide_FOUND 1)
15- set(Halide_VERSION @Halide_VERSION@)]] )
15+ file (CONFIGURE
16+ OUTPUT "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR} /HalideConfig.cmake"
17+ CONTENT [[ set(Halide_FOUND 1)
18+ set(Halide_VERSION @Halide_VERSION@)]]
19+ )
1620
17- file (CONFIGURE OUTPUT "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR} /HalideHelpersConfig.cmake"
18- CONTENT "set(HalideHelpers_FOUND 1)\n " )
21+ file (CONFIGURE
22+ OUTPUT "${CMAKE_FIND_PACKAGE_REDIRECTS_DIR} /HalideHelpersConfig.cmake"
23+ CONTENT "set(HalideHelpers_FOUND 1)\n "
24+ )
1925
2026##
2127# Set up project-wide properties
@@ -37,9 +43,10 @@ option(BUILD_SHARED_LIBS "Build shared libraries" ON)
3743get_property (is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
3844if (NOT is_multi_config AND CMAKE_BUILD_TYPE STREQUAL "" )
3945 string (JOIN "" error_message
40- "Halide cannot be built when CMAKE_BUILD_TYPE is empty. "
41- "Please set CMAKE_BUILD_TYPE to one of the standard types: "
42- "Debug, Release, RelWithDebInfo, or MinSizeRel." )
46+ "Halide cannot be built when CMAKE_BUILD_TYPE is empty. "
47+ "Please set CMAKE_BUILD_TYPE to one of the standard types: "
48+ "Debug, Release, RelWithDebInfo, or MinSizeRel."
49+ )
4350 message (FATAL_ERROR "${error_message} " )
4451endif ()
4552
@@ -58,11 +65,17 @@ set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
5865
5966# Require standard C++17
6067set (CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ standard to use. Halide requires 17 or higher." )
61- option (CMAKE_CXX_STANDARD_REQUIRED "When enabled, the value of CMAKE_CXX_STANDARD is a requirement." ON )
62- option (CMAKE_CXX_EXTENSIONS "When enabled, compiler-specific language extensions are enabled (e.g. -std=gnu++17)" OFF )
68+ option (CMAKE_CXX_STANDARD_REQUIRED
69+ "When enabled, the value of CMAKE_CXX_STANDARD is a requirement." ON
70+ )
71+ option (CMAKE_CXX_EXTENSIONS
72+ "When enabled, compiler-specific language extensions are enabled (e.g. -std=gnu++17)" OFF
73+ )
6374
6475if (CMAKE_CXX_STANDARD LESS 17)
65- message (FATAL_ERROR "Halide requires C++17 or newer but CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD } " )
76+ message (
77+ FATAL_ERROR "Halide requires C++17 or newer but CMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD } "
78+ )
6679endif ()
6780
6881# Build Halide with ccache if the package is present and the user requested it
@@ -74,11 +87,14 @@ if (Halide_CCACHE_BUILD)
7487 CCACHE_CPP2=yes
7588 CCACHE_HASHDIR=yes
7689 CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime,include_file_ctime
77- CACHE STRING "Parameters to pass through to ccache" )
90+ CACHE STRING "Parameters to pass through to ccache"
91+ )
7892 mark_as_advanced (Halide_CCACHE_PARAMS )
7993
8094 set (CMAKE_C_COMPILER_LAUNCHER ${CMAKE_COMMAND } -E env ${Halide_CCACHE_PARAMS} ${CCACHE_PROGRAM} )
81- set (CMAKE_CXX_COMPILER_LAUNCHER ${CMAKE_COMMAND } -E env ${Halide_CCACHE_PARAMS} ${CCACHE_PROGRAM} )
95+ set (CMAKE_CXX_COMPILER_LAUNCHER
96+ ${CMAKE_COMMAND } -E env ${Halide_CCACHE_PARAMS} ${CCACHE_PROGRAM}
97+ )
8298
8399 # Per https://ccache.dev/manual/latest.html#_precompiled_headers,
84100 # we must set -fno-pch-timestamp when using Clang + CCache + PCH
@@ -93,7 +109,9 @@ endif ()
93109# Detect whether or not ASAN is enabled. Don't cache the result to ensure this
94110# check happens every time we reconfigure.
95111unset (Halide_ASAN_ENABLED CACHE )
96- check_cxx_symbol_exists (HALIDE_INTERNAL_USING_ASAN "${Halide_SOURCE_DIR } /src/Util.h" Halide_ASAN_ENABLED )
112+ check_cxx_symbol_exists (
113+ HALIDE_INTERNAL_USING_ASAN "${Halide_SOURCE_DIR } /src/Util.h" Halide_ASAN_ENABLED
114+ )
97115
98116if (Halide_ASAN_ENABLED)
99117 set (Halide_ANY_SANITIZERS_ENABLED 1)
@@ -107,27 +125,22 @@ function(set_halide_compiler_warnings NAME)
107125 ${NAME}
108126 PRIVATE
109127 $<$<CXX_COMPILER_ID :GNU ,Clang ,AppleClang >:-Wall >
110-
111128 # variable length arrays in C++ are a Clang extension, we don't want to use them
112129 $<$<CXX_COMPILER_ID :Clang ,AppleClang >:-Wvla -extension >
113-
114130 $<$<CXX_COMPILER_ID :GNU ,Clang ,AppleClang >:-Wcast -qual >
115131 $<$<CXX_COMPILER_ID :GNU ,Clang ,AppleClang >:-Wignored -qualifiers >
116132 $<$<CXX_COMPILER_ID :GNU ,Clang ,AppleClang >:-Wimplicit -fallthrough >
117-
118133 # GCC warns when these warnings are given to plain-C sources
119134 $<$<COMPILE_LANG_AND_ID :CXX ,GNU ,Clang ,AppleClang >:-Woverloaded -virtual >
120135 $<$<COMPILE_LANG_AND_ID :CXX ,GNU >:-Wsuggest -override >
121-
122136 $<$<CXX_COMPILER_ID :Clang ,AppleClang >:-Winconsistent -missing -destructor -override >
123137 $<$<CXX_COMPILER_ID :Clang ,AppleClang >:-Winconsistent -missing -override >
124138 $<$<CXX_COMPILER_ID :GNU ,Clang ,AppleClang >:-Wdeprecated -declarations >
125-
126139 $<$<CXX_COMPILER_ID :MSVC >:/W3 >
127140 $<$<CXX_COMPILER_ID :MSVC >:/wd4018 > # 4018: disable "signed/unsigned mismatch"
128141 $<$<CXX_COMPILER_ID :MSVC >:/wd4146 > # 4146: unary minus applied to unsigned type
129142 $<$<CXX_COMPILER_ID :MSVC >:/wd4244 > # 4244: conversion, possible loss of data
130- $<$<CXX_COMPILER_ID :MSVC >:/wd4267 > # 4267: conversion from ' size_t' to ' int', possible loss of data
143+ $<$<CXX_COMPILER_ID :MSVC >:/wd4267 > # 4267: size_t -> int narrowing
131144 )
132145endfunction ()
133146
@@ -137,13 +150,17 @@ endfunction()
137150##
138151
139152## Threads
140- option (THREADS_PREFER_PTHREAD_FLAG "When enabled, prefer to use the -pthread flag to explicit linking" ON )
153+ option (THREADS_PREFER_PTHREAD_FLAG
154+ "When enabled, prefer to use the -pthread flag to explicit linking" ON
155+ )
141156find_package (Threads REQUIRED )
142157
143158## LLVM
144- find_package (Halide_LLVM 21...99 REQUIRED # Use 99 to fake a minimum-only constraint
145- COMPONENTS WebAssembly X86
146- OPTIONAL_COMPONENTS AArch64 ARM Hexagon NVPTX PowerPC RISCV )
159+ find_package (
160+ Halide_LLVM 21...99 REQUIRED # Use 99 to fake a minimum-only constraint
161+ COMPONENTS WebAssembly X86
162+ OPTIONAL_COMPONENTS AArch64 ARM Hexagon NVPTX PowerPC RISCV
163+ )
147164
148165_Halide_pkgdep (Halide_LLVM PACKAGE_VARS Halide_LLVM_SHARED_LIBS )
149166
@@ -167,23 +184,27 @@ find_package(PNG)
167184Halide_feature (Halide_BUILDING_IN_CI "Enable if building in CI" OFF ADVANCED )
168185
169186Halide_feature (Halide_ENABLE_EXCEPTIONS "Enable exceptions in Halide" ON )
170- Halide_feature (Halide_ENABLE_RTTI "Enable RTTI in Halide" ON
171- DEPENDS LLVM_ENABLE_RTTI )
187+ Halide_feature (Halide_ENABLE_RTTI "Enable RTTI in Halide" ON DEPENDS LLVM_ENABLE_RTTI )
172188
173- Halide_feature (WITH_AUTOSCHEDULERS "Build the Halide autoschedulers" ON
174- DEPENDS BUILD_SHARED_LIBS )
189+ Halide_feature (WITH_AUTOSCHEDULERS "Build the Halide autoschedulers" ON DEPENDS BUILD_SHARED_LIBS )
175190Halide_feature (WITH_DOCS "Halide's Doxygen documentation" OFF )
176191Halide_feature (WITH_PACKAGING "Halide's CMake package install rules" TOP_LEVEL )
177- Halide_feature (WITH_PYTHON_BINDINGS "Halide's native Python module (not the whole pip package)" ON
178- DEPENDS Halide_ENABLE_EXCEPTIONS AND Halide_ENABLE_RTTI )
192+ Halide_feature (
193+ WITH_PYTHON_BINDINGS "Halide's native Python module (not the whole pip package)" ON
194+ DEPENDS Halide_ENABLE_EXCEPTIONS AND Halide_ENABLE_RTTI
195+ )
179196Halide_feature (WITH_SERIALIZATION "Include experimental Serialization/Deserialization code" ON )
180- Halide_feature (WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING
181- "Intercepting JIT compilation with a serialization roundtrip, for test only"
182- OFF ADVANCED
183- DEPENDS WITH_SERIALIZATION )
197+ Halide_feature (
198+ WITH_SERIALIZATION_JIT_ROUNDTRIP_TESTING
199+ "Intercepting JIT compilation with a serialization roundtrip, for test only"
200+ OFF ADVANCED
201+ DEPENDS WITH_SERIALIZATION
202+ )
184203Halide_feature (WITH_TESTS "Halide's unit test suite" TOP_LEVEL )
185204Halide_feature (WITH_TUTORIALS "Halide's tutorial code" TOP_LEVEL )
186- Halide_feature (WITH_UTILS "Optional utility programs for Halide, including HalideTraceViz" TOP_LEVEL )
205+ Halide_feature (
206+ WITH_UTILS "Optional utility programs for Halide, including HalideTraceViz" TOP_LEVEL
207+ )
187208
188209
189210##
0 commit comments