88
99if (Halide_TARGET MATCHES "wasm" )
1010 set (_USING_WASM 1)
11- else ()
11+ else ()
1212 set (_USING_WASM 0)
13- endif ()
13+ endif ()
1414
1515function (add_wasm_executable TARGET )
1616 set (options )
@@ -31,7 +31,11 @@ function(add_wasm_executable TARGET)
3131 # target_link_libraries(${TARGET} PRIVATE ${args_DEPS})
3232 # endif ()
3333
34- find_program (EMCC emcc REQUIRED HINTS "$ENV{EMSDK} /upstream/emscripten" )
34+ find_program (
35+ EMCC emcc REQUIRED
36+ PATH_SUFFIXES upstream/emscripten
37+ HINTS ENV EMSDK
38+ )
3539
3640 # TODO: this is currently hardcoded to settings that are sensible for most of Halide's
3741 # internal purposes. Consider adding ways to customize this as appropriate.
@@ -127,22 +131,22 @@ function(_add_halide_libraries TARGET)
127131 # Passing on a no-value arg in CMake is unpleasant
128132 if (args_GRADIENT_DESCENT)
129133 set (GRADIENT_DESCENT_OPT "GRADIENT_DESCENT" )
130- else ()
134+ else ()
131135 set (GRADIENT_DESCENT_OPT "" )
132- endif ()
136+ endif ()
133137
134138 # Fill in default values for some arguments, as needed
135139 if (NOT args_FROM)
136140 add_halide_generator("${TARGET} .generator"
137141 SOURCES "${TARGET} _generator.cpp" )
138142 set (args_FROM "${TARGET} .generator" )
139- endif ()
143+ endif ()
140144 if (NOT args_GENERATOR_NAME)
141145 set (args_GENERATOR_NAME "${TARGET} " )
142- endif ()
146+ endif ()
143147 if (NOT args_FUNCTION_NAME)
144148 set (args_FUNCTION_NAME "${TARGET} " )
145- endif ()
149+ endif ()
146150
147151 set (TARGET_CPP "${TARGET} _cpp" )
148152
@@ -161,7 +165,7 @@ function(_add_halide_libraries TARGET)
161165 FUNCTION_INFO_HEADER function_info_header_out)
162166 if (args_EXTERNS)
163167 target_link_libraries (${TARGET} INTERFACE ${args_EXTERNS} )
164- endif ()
168+ endif ()
165169
166170 if (NOT args_OMIT_C_BACKEND)
167171 # The C backend basically ignores TARGETS (it emits a warning that the sources
@@ -186,7 +190,7 @@ function(_add_halide_libraries TARGET)
186190 FUNCTION_INFO_HEADER function_info_header_cpp_out)
187191 if (args_EXTERNS)
188192 target_link_libraries (${TARGET_CPP} INTERFACE ${args_EXTERNS} )
189- endif ()
193+ endif ()
190194 # This is a bit subtle: we end up emitting NAME.h and NAME_cpp.h header files;
191195 # these are *identical* in content (aside from the guard macro and the filename).
192196 # For convenience, we use the NAME.h variant in all cases downstream (even when linking
@@ -195,7 +199,7 @@ function(_add_halide_libraries TARGET)
195199 # on NAME.h already being generated.) This is a bit suboptimal, but it is arguably better
196200 # that having conditionalized #includes in all the downstream test targets.
197201 add_dependencies (${TARGET_CPP} ${TARGET} )
198- endif ()
202+ endif ()
199203endfunction ()
200204
201205function (_add_one_aot_test TARGET )
@@ -256,17 +260,17 @@ function(_add_halide_aot_tests NAME)
256260 # with a matching name
257261 if (NOT args_HALIDE_LIBRARIES)
258262 set (args_HALIDE_LIBRARIES "${NAME} " )
259- endif ()
263+ endif ()
260264
261265 # If no Halide runtime specified, use one from the first halide_library in the list
262266 if (NOT args_HALIDE_RUNTIME)
263267 list (GET args_HALIDE_LIBRARIES 0 HR)
264268 set (args_HALIDE_RUNTIME "${HR} .runtime" )
265- endif ()
269+ endif ()
266270
267271 if (NOT args_SRCS)
268272 set (args_SRCS "${NAME} _aottest.cpp" )
269- endif ()
273+ endif ()
270274
271275 set (TARGET "generator_aot_${NAME} " )
272276 set (TARGET_CPP "generator_aotcpp_${NAME} " )
@@ -288,7 +292,7 @@ function(_add_halide_aot_tests NAME)
288292 "${Halide_SOURCE_DIR} /tools"
289293 "${CMAKE_CURRENT_BINARY_DIR} " )
290294 add_wasm_halide_test("${TARGET} " GROUPS generator "${args_GROUPS} " )
291- else ()
295+ else ()
292296 _add_one_aot_test("${TARGET} "
293297 SRCS "${args_SRCS} "
294298 DEPS ${args_HALIDE_LIBRARIES} ${args_HALIDE_RUNTIME} ${args_DEPS}
@@ -298,14 +302,14 @@ function(_add_halide_aot_tests NAME)
298302 set (HALIDE_LIBRARIES_CPP "" )
299303 foreach (hl IN LISTS args_HALIDE_LIBRARIES)
300304 list (APPEND HALIDE_LIBRARIES_CPP "${hl} _cpp" )
301- endforeach ()
305+ endforeach ()
302306 _add_one_aot_test("${TARGET_CPP} "
303307 SRCS "${args_SRCS} "
304308 DEPS ${HALIDE_LIBRARIES_CPP} ${args_HALIDE_RUNTIME} ${args_DEPS}
305309 INCLUDES ${args_INCLUDES}
306310 GROUPS ${args_GROUPS} )
307- endif ()
308- endif ()
311+ endif ()
312+ endif ()
309313endfunction ()
310314
311315if ("NVPTX" IN_LIST Halide_LLVM_COMPONENTS)
@@ -585,9 +589,9 @@ if (${_USING_WASM})
585589elseif (Halide_CMAKE_TARGET MATCHES ";" )
586590 # multiarch doesn't support multitargets
587591 set (MDT_TARGETS cmake)
588- else ()
592+ else ()
589593 set (MDT_TARGETS cmake-no_bounds_query cmake)
590- endif ()
594+ endif ()
591595
592596_add_halide_libraries(metadata_tester
593597 PARAMS ${metadata_tester_params}
@@ -609,15 +613,15 @@ _add_halide_aot_tests(metal_completion_handler_override)
609613# msan_generator.cpp
610614if ("${Halide_TARGET} " MATCHES "webgpu" )
611615 message (WARNING "Test generator_aot_msan is not supported under WebGPU" )
612- else ()
616+ else ()
613617 _add_halide_libraries(msan
614618 FEATURES msan
615619 # Broken for C++ backend (https://github.com/halide/Halide/issues/7273)
616620 OMIT_C_BACKEND)
617621 _add_halide_aot_tests(msan
618622 OMIT_C_BACKEND
619623 GROUPS multithreaded)
620- endif ()
624+ endif ()
621625
622626# (Doesn't build/link properly on windows / under wasm)
623627if (NOT Halide_TARGET MATCHES "windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT ${_USING_WASM} )
@@ -635,11 +639,11 @@ if (NOT _USING_WASM AND NOT Halide_CMAKE_TARGET MATCHES ";")
635639 # multitarget_aottest.cpp
636640 # multitarget_generator.cpp
637641 _add_halide_libraries(multitarget
638- # ... or to the C backend
639- OMIT_C_BACKEND
640- TARGETS cmake-no_bounds_query cmake
641- FEATURES c_plus_plus_name_mangling
642- FUNCTION_NAME HalideTest::multitarget)
642+ # ... or to the C backend
643+ OMIT_C_BACKEND
644+ TARGETS cmake-no_bounds_query cmake
645+ FEATURES c_plus_plus_name_mangling
646+ FUNCTION_NAME HalideTest::multitarget)
643647
644648 # Note that we make two tests here so that we can run it two ways,
645649 # to ensure that both target paths are taken.
@@ -678,7 +682,7 @@ _add_halide_aot_tests(output_assign)
678682
679683# pyramid_aottest.cpp
680684# pyramid_generator.cpp
681- _add_halide_libraries(pyramid PARAMS levels=10 )
685+ _add_halide_libraries(pyramid PARAMS levels=10)
682686_add_halide_aot_tests(pyramid GROUPS multithreaded)
683687
684688# rdom_input_aottest.cpp
0 commit comments