diff --git a/src/00common/CMakeLists.txt b/src/00common/CMakeLists.txt index 6e37fada..f906308e 100644 --- a/src/00common/CMakeLists.txt +++ b/src/00common/CMakeLists.txt @@ -7,5 +7,8 @@ target_link_libraries(common PUBLIC fmt) target_include_directories(common PUBLIC include) file(GLOB_RECURSE COMMON_TEST test/*.cpp) -add_executable(common_test ${COMMON_TEST}) -target_link_libraries(common_test common GTest::gtest_main) +if(COMMON_TEST) + add_executable(common_test ${COMMON_TEST}) + target_link_libraries(common_test common GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(common_test) +endif() diff --git a/src/01graph_topo/CMakeLists.txt b/src/01graph_topo/CMakeLists.txt index f6daa358..b0d4eb70 100644 --- a/src/01graph_topo/CMakeLists.txt +++ b/src/01graph_topo/CMakeLists.txt @@ -6,7 +6,9 @@ add_library(graph_topo STATIC ${GRAPH_TOPO_SRC}) target_link_libraries(graph_topo PUBLIC common) target_include_directories(graph_topo PUBLIC include) -file(GLOB_RECURSE GRAPH_TEST test/*.cpp) -add_executable(graph_topo_test ${GRAPH_TEST}) -target_link_libraries(graph_topo_test graph_topo GTest::gtest_main ${BACKWARD_ENABLE}) -add_backward(graph_topo_test) +file(GLOB_RECURSE GRAPH_TOPO_TEST test/*.cpp) +if(GRAPH_TOPO_TEST) + add_executable(graph_topo_test ${GRAPH_TOPO_TEST}) + target_link_libraries(graph_topo_test graph_topo GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(graph_topo_test) +endif() diff --git a/src/02mem_manager/CMakeLists.txt b/src/02mem_manager/CMakeLists.txt index 5796e954..7e6b193a 100644 --- a/src/02mem_manager/CMakeLists.txt +++ b/src/02mem_manager/CMakeLists.txt @@ -5,3 +5,10 @@ file(GLOB_RECURSE MEM_MANAGER_SRC src/*.cc src/*.cpp) add_library(mem_manager STATIC ${MEM_MANAGER_SRC}) target_link_libraries(mem_manager PUBLIC common) target_include_directories(mem_manager PUBLIC include) + +file(GLOB_RECURSE MEM_MANAGER_TEST test/*.cpp) +if(MEM_MANAGER_TEST) + add_executable(mem_manager_test ${MEM_MANAGER_TEST}) + target_link_libraries(mem_manager_test mem_manager GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(mem_manager_test) +endif() diff --git a/src/03runtime/CMakeLists.txt b/src/03runtime/CMakeLists.txt index 916c2113..57c6b003 100644 --- a/src/03runtime/CMakeLists.txt +++ b/src/03runtime/CMakeLists.txt @@ -5,3 +5,10 @@ file(GLOB_RECURSE RUNTIME_SRC src/*.cc src/*.cpp) add_library(runtime STATIC ${RUNTIME_SRC}) target_link_libraries(runtime PUBLIC graph_topo mem_manager) target_include_directories(runtime PUBLIC include) + +file(GLOB_RECURSE RUNTIME_TEST test/*.cpp) +if(RUNTIME_TEST) + add_executable(runtime_test ${RUNTIME_TEST}) + target_link_libraries(runtime_test runtime GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(runtime_test) +endif() diff --git a/src/04kernel/CMakeLists.txt b/src/04kernel/CMakeLists.txt index 0b7c9f84..b21e9cbf 100644 --- a/src/04kernel/CMakeLists.txt +++ b/src/04kernel/CMakeLists.txt @@ -24,3 +24,10 @@ if(USE_CUDA) target_link_libraries(cuda_kernel PUBLIC cudnn runtime) target_link_libraries(kernel PUBLIC cuda_kernel) endif() + +file(GLOB_RECURSE KERNEL_TEST test/*.cpp) +if(KERNEL_TEST) + add_executable(kernel_test ${KERNEL_TEST}) + target_link_libraries(kernel_test kernel GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(kernel_test) +endif() diff --git a/src/05computation/CMakeLists.txt b/src/05computation/CMakeLists.txt index beed101d..dbbf8732 100644 --- a/src/05computation/CMakeLists.txt +++ b/src/05computation/CMakeLists.txt @@ -5,3 +5,10 @@ file(GLOB_RECURSE COMPUTATION_SRC src/*.cc src/*.cpp) add_library(computation STATIC ${COMPUTATION_SRC}) target_link_libraries(computation PUBLIC kernel) target_include_directories(computation PUBLIC include) + +file(GLOB_RECURSE COMPUTATION_TEST test/*.cpp) +if(COMPUTATION_TEST) + add_executable(computation_test ${COMPUTATION_TEST}) + target_link_libraries(computation_test computation GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(computation_test) +endif() diff --git a/src/06frontend/CMakeLists.txt b/src/06frontend/CMakeLists.txt index 77990c4c..ca687a6a 100644 --- a/src/06frontend/CMakeLists.txt +++ b/src/06frontend/CMakeLists.txt @@ -6,7 +6,9 @@ add_library(frontend STATIC ${FRONTEND_SRC}) target_link_libraries(frontend PUBLIC computation) target_include_directories(frontend PUBLIC include) -# file(GLOB_RECURSE FRONTEND_TEST test/*.cpp) -# add_executable(frontend_test ${FRONTEND_TEST}) -# target_link_libraries(frontend_test frontend GTest::gtest_main ${BACKWARD_ENABLE}) -# add_backward(frontend_test) +file(GLOB_RECURSE FRONTEND_TEST test/*.cpp) +if(FRONTEND_TEST) + add_executable(frontend_test ${FRONTEND_TEST}) + target_link_libraries(frontend_test frontend GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(frontend_test) +endif() diff --git a/src/07onnx/CMakeLists.txt b/src/07onnx/CMakeLists.txt index 94afe6a8..1d4bbbd1 100644 --- a/src/07onnx/CMakeLists.txt +++ b/src/07onnx/CMakeLists.txt @@ -7,6 +7,8 @@ target_link_libraries(onnx PUBLIC frontend) target_include_directories(onnx PUBLIC include) file(GLOB_RECURSE ONNX_TEST test/*.cpp) -add_executable(onnx_test ${ONNX_TEST}) -target_link_libraries(onnx_test onnx GTest::gtest_main ${BACKWARD_ENABLE}) -add_backward(onnx_test) +if(ONNX_TEST) + add_executable(onnx_test ${ONNX_TEST}) + target_link_libraries(onnx_test onnx GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(onnx_test) +endif() diff --git a/src/08communication/CMakeLists.txt b/src/08communication/CMakeLists.txt index 2a075ff2..45c4e2db 100644 --- a/src/08communication/CMakeLists.txt +++ b/src/08communication/CMakeLists.txt @@ -6,7 +6,9 @@ add_library(communication STATIC ${COMMUNICATION_SRC}) target_link_libraries(communication PUBLIC frontend) target_include_directories(communication PUBLIC include) -# file(GLOB_RECURSE ONNX_TEST test/*.cpp) -# add_executable(onnx_test ${ONNX_TEST}) -# target_link_libraries(onnx_test onnx GTest::gtest_main ${BACKWARD_ENABLE}) -# add_backward(onnx_test) +file(GLOB_RECURSE COMMUNICATION_TEST test/*.cpp) +if(COMMUNICATION_TEST) + add_executable(communication_test ${COMMUNICATION_TEST}) + target_link_libraries(communication_test communication GTest::gtest_main ${BACKWARD_ENABLE}) + add_backward(communication_test) +endif()