Skip to content

Commit 2facfd8

Browse files
committed
test: refactor dtype dispatch compile-fail test target
1 parent b594867 commit 2facfd8

1 file changed

Lines changed: 5 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -217,28 +217,12 @@ link_infini_train_exe(test_dtype_dispatch)
217217
set(DTYPE_DISPATCH_COMPILE_FAIL_SOURCE
218218
${PROJECT_SOURCE_DIR}/test/dtype/test_dtype_dispatch_compile_fail.cc)
219219

220-
try_compile(DTYPE_DISPATCH_COMPILE_UNEXPECTEDLY_SUCCEEDED
221-
${CMAKE_BINARY_DIR}/CMakeFiles/try_compile_dtype_dispatch_missing_map
222-
SOURCES ${DTYPE_DISPATCH_COMPILE_FAIL_SOURCE}
223-
CMAKE_FLAGS
224-
"-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}"
225-
"-DCMAKE_CXX_STANDARD_REQUIRED=ON"
226-
"-DCMAKE_CXX_EXTENSIONS=OFF"
227-
"-DCMAKE_CXX_FLAGS=-I${PROJECT_SOURCE_DIR}"
228-
OUTPUT_VARIABLE DTYPE_DISPATCH_TRY_COMPILE_OUTPUT
220+
add_executable(test_dtype_dispatch_compile_fail EXCLUDE_FROM_ALL
221+
${DTYPE_DISPATCH_COMPILE_FAIL_SOURCE}
229222
)
230223

231-
if(DTYPE_DISPATCH_COMPILE_UNEXPECTEDLY_SUCCEEDED)
232-
message(FATAL_ERROR
233-
"dtype dispatch compile-fail test unexpectedly succeeded.\n"
234-
"Source: ${DTYPE_DISPATCH_COMPILE_FAIL_SOURCE}\n"
235-
"Output:\n${DTYPE_DISPATCH_TRY_COMPILE_OUTPUT}")
236-
endif()
237-
238-
add_custom_target(test_dtype_dispatch_compile_fail
239-
COMMAND ${CMAKE_COMMAND} -E echo
240-
"dtype dispatch compile-fail check passed (missing dtype registration correctly fails to compile)."
241-
VERBATIM
224+
target_include_directories(test_dtype_dispatch_compile_fail PRIVATE
225+
${PROJECT_SOURCE_DIR}
242226
)
243227

244-
add_dependencies(test_dtype_dispatch test_dtype_dispatch_compile_fail)
228+
link_infini_train_exe(test_dtype_dispatch_compile_fail)

0 commit comments

Comments
 (0)