|
|
|
@ -29,24 +29,10 @@
|
|
|
|
|
# https://cmake.org/cmake/help/v3.0/module/CMakeParseArguments.html
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# generic.cmake depends on {GLOG,GFLAGS,GTEST,GTEST_MAIN}_LIBRARIES
|
|
|
|
|
# generated by cmake/external/*.cmake.
|
|
|
|
|
|
|
|
|
|
# Because gflags depends on pthread, I copied the following snippet
|
|
|
|
|
# from https://stackoverflow.com/a/29871891/724872.
|
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
|
|
|
|
function(link_glog_gflags TARGET_NAME)
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${GLOG_LIBRARIES} ${GFLAGS_LIBRARIES} Threads::Threads)
|
|
|
|
|
add_dependencies(${TARGET_NAME} glog gflags)
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
function(link_gtest TARGET_NAME)
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
|
|
|
|
|
add_dependencies(${TARGET_NAME} gtest)
|
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
if(NOT APPLE)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
link_libraries(${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
|
endif(NOT APPLE)
|
|
|
|
|
|
|
|
|
|
# cc_library parses tensor.cc and figures out that target also depend on tensor.h.
|
|
|
|
|
# cc_library(tensor
|
|
|
|
@ -83,7 +69,6 @@ function(cc_binary TARGET_NAME)
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${cc_binary_DEPS})
|
|
|
|
|
add_dependencies(${TARGET_NAME} ${cc_binary_DEPS})
|
|
|
|
|
endif()
|
|
|
|
|
link_glog_gflags(${TARGET_NAME})
|
|
|
|
|
endfunction(cc_binary)
|
|
|
|
|
|
|
|
|
|
# The dependency to target tensor implies that if any of
|
|
|
|
@ -100,12 +85,8 @@ function(cc_test TARGET_NAME)
|
|
|
|
|
set(multiValueArgs SRCS DEPS)
|
|
|
|
|
cmake_parse_arguments(cc_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
add_executable(${TARGET_NAME} ${cc_test_SRCS})
|
|
|
|
|
if(cc_test_DEPS)
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${cc_test_DEPS})
|
|
|
|
|
add_dependencies(${TARGET_NAME} ${cc_test_DEPS})
|
|
|
|
|
endif()
|
|
|
|
|
link_glog_gflags(${TARGET_NAME})
|
|
|
|
|
link_gtest(${TARGET_NAME})
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${cc_test_DEPS} gtest gtest_main)
|
|
|
|
|
add_dependencies(${TARGET_NAME} ${cc_test_DEPS} gtest gtest_main)
|
|
|
|
|
add_test(${TARGET_NAME} ${TARGET_NAME})
|
|
|
|
|
endif()
|
|
|
|
|
endfunction(cc_test)
|
|
|
|
@ -146,7 +127,6 @@ function(nv_binary TARGET_NAME)
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${nv_binary_DEPS})
|
|
|
|
|
add_dependencies(${TARGET_NAME} ${nv_binary_DEPS})
|
|
|
|
|
endif()
|
|
|
|
|
link_glog_gflags(${TARGET_NAME})
|
|
|
|
|
endif()
|
|
|
|
|
endfunction(nv_binary)
|
|
|
|
|
|
|
|
|
@ -164,12 +144,8 @@ function(nv_test TARGET_NAME)
|
|
|
|
|
set(multiValueArgs SRCS DEPS)
|
|
|
|
|
cmake_parse_arguments(nv_test "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
|
cuda_add_executable(${TARGET_NAME} ${nv_test_SRCS})
|
|
|
|
|
if(nv_test_DEPS)
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${nv_test_DEPS})
|
|
|
|
|
add_dependencies(${TARGET_NAME} ${nv_test_DEPS})
|
|
|
|
|
endif()
|
|
|
|
|
link_glog_gflags(${TARGET_NAME})
|
|
|
|
|
link_gtest(${TARGET_NAME})
|
|
|
|
|
target_link_libraries(${TARGET_NAME} ${nv_test_DEPS} gtest gtest_main)
|
|
|
|
|
add_dependencies(${TARGET_NAME} ${nv_test_DEPS} gtest gtest_main)
|
|
|
|
|
add_test(${TARGET_NAME} ${TARGET_NAME})
|
|
|
|
|
endif()
|
|
|
|
|
endfunction(nv_test)
|
|
|
|
|