1717# It should also be cmake-lint clean. 
1818# 
1919
20- include (${EXECUTORCH_ROOT} /build /Utils.cmake)
21- 
22- # Find prebuilt executorch library 
23- find_package (executorch CONFIG REQUIRED)
24- 
25- enable_testing ()
26- find_package (GTest CONFIG REQUIRED)
27- 
28- target_link_options_shared_lib(cpuinfo)
29- target_link_options_shared_lib(extension_data_loader)
30- target_link_options_shared_lib(portable_kernels)
31- target_link_options_shared_lib(portable_ops_lib)
32- target_link_options_shared_lib(pthreadpool)
33- target_link_options_shared_lib(quantized_ops_lib)
34- 
35- # Add code coverage flags to supported compilers 
36- if (EXECUTORCH_USE_CPP_CODE_COVERAGE)
37-   if ("${CMAKE_CXX_COMPILER_ID} "  STREQUAL  "GNU" )
38-     string (APPEND  CMAKE_C_FLAGS " --coverage -fprofile-abs-path" )
39-     string (APPEND  CMAKE_CXX_FLAGS  " --coverage -fprofile-abs-path" )
40-   elseif ("${CMAKE_CXX_COMPILER_ID} "  MATCHES  "Clang" )
41-     string (APPEND  CMAKE_C_FLAGS " -fprofile-instr-generate -fcoverage-mapping" )
42-     string (APPEND  CMAKE_CXX_FLAGS 
43-            " -fprofile-instr-generate -fcoverage-mapping" 
44-     )
45-   else ()
46-     message (ERROR
47-             "Code coverage for compiler ${CMAKE_CXX_COMPILER_ID}  is unsupported" 
48-     )
49-   endif ()
50- endif ()
51- 
5220# A helper function to generate a gtest cxx executable target @param 
5321# target_name: name for the executable @param SOURCES <list_of_sources>: test 
5422# sources to be compiled. Sometimes util sources are used as well @param EXTRA 
@@ -67,24 +35,14 @@ function(et_cxx_test target_name)
6735  set (multi_arg_names SOURCES  EXTRA_LIBS)
6836  cmake_parse_arguments (ET_CXX_TEST ""  ""  "${multi_arg_names} "  ${ARGN} )
6937
70-   # Let files say "include <executorch/path/to/header.h>". 
71-   target_include_directories (executorch INTERFACE  ${EXECUTORCH_ROOT} /..)
72- 
73-   set (ET_TEST_UTIL_SOURCES
74-       ${EXECUTORCH_ROOT} /runtime/core/exec_aten/testing_util/tensor_util.cpp
75-   )
76- 
77-   add_executable (${target_name}  ${ET_CXX_TEST_SOURCES}  ${ET_TEST_UTIL_SOURCES} )
38+   add_executable (${target_name}  ${ET_CXX_TEST_SOURCES}  ${EXECUTORCH_ROOT} /runtime/core/exec_aten/testing_util/tensor_util.cpp)
7839  # Includes gtest, gmock, executorch by default 
7940  target_link_libraries (
8041    ${target_name}  GTest::gtest GTest::gtest_main GTest::gmock executorch
8142    ${ET_CXX_TEST_EXTRA_LIBS} 
8243  )
8344
84-   # add_test adds a test target to be used by ctest. We use `ExecuTorchTest` as 
85-   # the ctest target name for the test executable Usage: cd 
86-   # cmake-out/path/to/test/; ctest Note: currently we directly invoke the test 
87-   # target, without using ctest 
88-   add_test (ExecuTorchTest ${target_name} )
45+   # add_test adds a test target to be used by ctest 
46+   add_test (NAME  ${target_name}  COMMAND  ${target_name} )
8947
9048endfunction ()
0 commit comments