@@ -4,6 +4,7 @@ option(USE_CUDA "Support NVIDIA CUDA" OFF)
44option (PROFILE_MODE "ENABLE PROFILE MODE" OFF )
55option (USE_OMP "Use OpenMP as backend for Eigen" ON )
66option (USE_NCCL "Build project for distributed running" ON )
7+ option (BUILD_TEST "Build InfiniTrain tests" ON )
78
89project (infini_train VERSION 0.5.0 LANGUAGES CXX )
910
@@ -14,6 +15,21 @@ set(CMAKE_CXX_EXTENSIONS OFF)
1415# Generate compile_commands.json
1516set (CMAKE_EXPORT_COMPILE_COMMANDS ON )
1617
18+ # ------------------------------------------------------------------------------
19+ # GoogleTest (FetchContent)
20+ # ------------------------------------------------------------------------------
21+ if (BUILD_TEST)
22+ include (FetchContent )
23+ FetchContent_Declare (
24+ googletest
25+ GIT_REPOSITORY https://github.com/google/googletest.git
26+ GIT_TAG v1.14.0
27+ )
28+ set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
29+ FetchContent_MakeAvailable (googletest)
30+ enable_testing ()
31+ endif ()
32+
1733# ------------------------------------------------------------------------------
1834# Third-party deps
1935# ------------------------------------------------------------------------------
@@ -26,7 +42,9 @@ include_directories(${gflags_SOURCE_DIR}/include)
2642set (WITH_GFLAGS OFF CACHE BOOL "Disable glog finding system gflags" FORCE )
2743set (WITH_GTEST OFF CACHE BOOL "Disable glog finding system gtest" FORCE )
2844add_subdirectory (third_party/glog )
45+ add_compile_definitions (GLOG_USE_GLOG_EXPORT=1 )
2946include_directories (${glog_SOURCE_DIR} /src )
47+ include_directories (${glog_BINARY_DIR} /glog )
3048
3149# eigen
3250if (USE_OMP)
@@ -48,6 +66,8 @@ endif()
4866# Framework core sources (*.cc), excluding cpu kernels (they are built separately)
4967file (GLOB_RECURSE SRC ${PROJECT_SOURCE_DIR} /infini_train/src/*.cc )
5068list (FILTER SRC EXCLUDE REGEX ".*kernels/cpu/.*" )
69+ list (FILTER SRC EXCLUDE REGEX ".*runtime/cuda/.*" )
70+ list (FILTER SRC EXCLUDE REGEX ".*ccl/cuda/.*" )
5171if (NOT USE_NCCL)
5272 list (FILTER SRC EXCLUDE REGEX ".*infini_train/src/core/ccl/cuda/.*" )
5373endif ()
@@ -190,17 +210,8 @@ add_executable(llama3
190210)
191211link_infini_train_exe (llama3 )
192212
193- # Tools
194- add_subdirectory (tools/infini_run )
195- set_target_properties (infini_run PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
196213
197214# Tests
198- add_executable (test_hook test /hook/test_hook.cc )
199- link_infini_train_exe (test_hook )
200-
201- add_executable (test_precision_check test /hook/test_precision_check.cc )
202- link_infini_train_exe (test_precision_check )
203-
204- add_executable (test_lora test /lora/test_lora.cc )
205- link_infini_train_exe (test_lora )
206-
215+ if (BUILD_TEST)
216+ add_subdirectory (tests )
217+ endif ()
0 commit comments