This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
/
CMakeLists.txt
62 lines (52 loc) · 1.68 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# ---[ Google Test
if(NOT GTEST_ROOT)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/googletest")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/googletest")
set(GTEST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/googletest")
set(GTEST_BOTH_LIBRARIES gtest gtest_main)
set(GTEST_FOUND ON)
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/gtest")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/gtest")
set(GTEST_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/gtest")
set(GTEST_BOTH_LIBRARIES gtest gtest_main)
set(GTEST_FOUND ON)
else()
find_package(GTest)
endif()
endif()
if(NOT MSVC)
set(UNITTEST_STATIC_LINK ON)
endif()
# FIXME MSVC unit test linking issue
if(GTEST_FOUND AND NOT MSVC)
enable_testing()
file(GLOB_RECURSE UNIT_TEST_SOURCE "cpp/*.cc" "cpp/*.h")
include_directories(cpp/include)
if (NOT PRIVATE_RUNTIME_DIR)
set(PRIVATE_RUNTIME_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
add_executable(${PROJECT_NAME}_unit_tests ${UNIT_TEST_SOURCE})
set_property(TARGET ${PROJECT_NAME}_unit_tests
PROPERTY RUNTIME_OUTPUT_DIRECTORY ${PRIVATE_RUNTIME_DIR})
if(UNITTEST_STATIC_LINK)
target_link_libraries(${PROJECT_NAME}_unit_tests
${GTEST_LIBRARY}
${BEGIN_WHOLE_ARCHIVE} mxnet_static ${END_WHOLE_ARCHIVE}
dmlc
${mxnet_LINKER_LIBS}
${pslite_LINKER_LIBS}
)
else()
target_link_libraries(${PROJECT_NAME}_unit_tests
${GTEST_LIBRARY}
dmlc
${nnvm_LINKER_LIBS}
${mxnet_LINKER_LIBS}
mxnet
${pslite_LINKER_LIBS}
)
endif()
add_test(AllTestsIn${PROJECT_NAME}UnitTests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}_unit_tests)
else()
message(WARNING "Google Test not found")
endif()