Skip to content

Commit

Permalink
Fix CMake test for generator_aot_multitarget (#7716)
Browse files Browse the repository at this point in the history
* Fix CMake test for generator_aot_multitarget

* Update CMakeLists.txt
  • Loading branch information
steven-johnson authored Jul 27, 2023
1 parent df4c981 commit 649a224
Showing 1 changed file with 33 additions and 17 deletions.
50 changes: 33 additions & 17 deletions test/generator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ endfunction()
function(_add_halide_aot_tests NAME)
set(options OMIT_C_BACKEND)
set(oneValueArgs "")
set(multiValueArgs ENABLE_IF GROUPS INCLUDES HALIDE_LIBRARIES HALIDE_RUNTIME DEPS)
set(multiValueArgs ENABLE_IF GROUPS INCLUDES HALIDE_LIBRARIES HALIDE_RUNTIME DEPS SRCS)
cmake_parse_arguments(args "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (args_ENABLE_IF AND NOT (${args_ENABLE_IF}))
Expand All @@ -169,6 +169,10 @@ function(_add_halide_aot_tests NAME)
set(args_HALIDE_RUNTIME "${HR}.runtime")
endif()

if (NOT args_SRCS)
set(args_SRCS "${NAME}_aottest.cpp")
endif()

set(TARGET "generator_aot_${NAME}")
set(TARGET_CPP "generator_aotcpp_${NAME}")

Expand All @@ -179,7 +183,7 @@ function(_add_halide_aot_tests NAME)
list(APPEND args_INCLUDES "${Halide_SOURCE_DIR}/src/runtime")
endif ()
add_wasm_executable("${TARGET}"
SRCS "${NAME}_aottest.cpp"
SRCS "${args_SRCS}"
DEPS ${args_HALIDE_LIBRARIES} ${args_HALIDE_RUNTIME} ${args_DEPS}
OPTIONS "${OPTIONS}"
INCLUDES
Expand All @@ -191,7 +195,7 @@ function(_add_halide_aot_tests NAME)
add_wasm_halide_test("${TARGET}" GROUPS generator "${args_GROUPS}")
else()
_add_one_aot_test("${TARGET}"
SRCS "${NAME}_aottest.cpp"
SRCS "${args_SRCS}"
DEPS ${args_HALIDE_LIBRARIES} ${args_HALIDE_RUNTIME} ${args_DEPS}
INCLUDES ${args_INCLUDES}
GROUPS ${args_GROUPS})
Expand All @@ -201,7 +205,7 @@ function(_add_halide_aot_tests NAME)
list(APPEND HALIDE_LIBRARIES_CPP "${hl}_cpp")
endforeach()
_add_one_aot_test("${TARGET_CPP}"
SRCS "${NAME}_aottest.cpp"
SRCS "${args_SRCS}"
DEPS ${HALIDE_LIBRARIES_CPP} ${args_HALIDE_RUNTIME} ${args_DEPS}
INCLUDES ${args_INCLUDES}
GROUPS ${args_GROUPS})
Expand Down Expand Up @@ -513,19 +517,31 @@ if (NOT Halide_TARGET MATCHES "windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Windo
_add_halide_aot_tests(sanitizercoverage OMIT_C_BACKEND)
endif ()

# multitarget_aottest.cpp
# multitarget_generator.cpp
_add_halide_libraries(multitarget
# Multitarget doesn't apply to WASM...
ENABLE_IF NOT ${_USING_WASM}
# ... or to the C backend
OMIT_C_BACKEND
TARGETS cmake-no_bounds_query cmake
FEATURES c_plus_plus_name_mangling
FUNCTION_NAME HalideTest::multitarget)
_add_halide_aot_tests(multitarget
ENABLE_IF NOT ${_USING_WASM}
OMIT_C_BACKEND)
# multitarget and wasm don't mix well
if (NOT _USING_WASM)
# multitarget_aottest.cpp
# multitarget_generator.cpp
_add_halide_libraries(multitarget
# ... or to the C backend
OMIT_C_BACKEND
TARGETS cmake-no_bounds_query cmake
FEATURES c_plus_plus_name_mangling
FUNCTION_NAME HalideTest::multitarget)

# Note that we make two tests here so that we can run it two ways,
# to ensure that both target paths are taken.
_add_halide_aot_tests(multitarget_0
SRCS multitarget_aottest.cpp
HALIDE_LIBRARIES multitarget
OMIT_C_BACKEND)
set_tests_properties(generator_aot_multitarget_0 PROPERTIES ENVIRONMENT "HL_MULTITARGET_TEST_USE_NOBOUNDSQUERY_FEATURE=0")

_add_halide_aot_tests(multitarget_1
SRCS multitarget_aottest.cpp
HALIDE_LIBRARIES multitarget
OMIT_C_BACKEND)
set_tests_properties(generator_aot_multitarget_1 PROPERTIES ENVIRONMENT "HL_MULTITARGET_TEST_USE_NOBOUNDSQUERY_FEATURE=1")
endif ()

# nested_externs_aottest.cpp
# nested_externs_generator.cpp
Expand Down

0 comments on commit 649a224

Please sign in to comment.