From bdf155981f88d336f4479bf4c52092c0852afcda Mon Sep 17 00:00:00 2001 From: Yixiao Chen Date: Mon, 21 Jun 2021 20:32:44 -0400 Subject: [PATCH 1/3] fix bug when trying to find gtest in cmake --- source/api_cc/tests/CMakeLists.txt | 2 +- source/lib/tests/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/api_cc/tests/CMakeLists.txt b/source/api_cc/tests/CMakeLists.txt index 111c7646bb..bd7b5314bd 100644 --- a/source/api_cc/tests/CMakeLists.txt +++ b/source/api_cc/tests/CMakeLists.txt @@ -105,7 +105,7 @@ endif() add_test( runUnitTests runUnitTests ) find_package(GTest) -if(NOT GTEST_LIBRARY) +if(NOT GTEST_LIBRARIES) configure_file(../../cmake/googletest.cmake.in googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result diff --git a/source/lib/tests/CMakeLists.txt b/source/lib/tests/CMakeLists.txt index b12734af9b..b5a0460c54 100644 --- a/source/lib/tests/CMakeLists.txt +++ b/source/lib/tests/CMakeLists.txt @@ -87,7 +87,7 @@ add_test( runUnitTests runUnitTests ) # ) find_package(GTest) -if(NOT GTEST_LIBRARY) +if(NOT GTEST_LIBRARIES) configure_file(../../cmake/googletest.cmake.in googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result From f93b46852528bd433c826a1ebd4fee2e33bb9319 Mon Sep 17 00:00:00 2001 From: Yixiao Chen Date: Mon, 21 Jun 2021 22:14:15 -0400 Subject: [PATCH 2/3] link librt explicitly --- source/api_cc/tests/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/api_cc/tests/CMakeLists.txt b/source/api_cc/tests/CMakeLists.txt index bd7b5314bd..6768ff2ee6 100644 --- a/source/api_cc/tests/CMakeLists.txt +++ b/source/api_cc/tests/CMakeLists.txt @@ -95,11 +95,11 @@ else() endif() if (USE_CUDA_TOOLKIT) - target_link_libraries(runUnitTests gtest gtest_main ${libname} ${apiname} ${opname} pthread ${TensorFlow_LIBRARY} deepmd_op_cuda coverage_config) + target_link_libraries(runUnitTests gtest gtest_main ${libname} ${apiname} ${opname} pthread ${TensorFlow_LIBRARY} rt deepmd_op_cuda coverage_config) elseif(USE_ROCM_TOOLKIT) - target_link_libraries(runUnitTests gtest gtest_main ${libname} ${apiname} ${opname} pthread ${TensorFlow_LIBRARY} deepmd_op_rocm coverage_config) + target_link_libraries(runUnitTests gtest gtest_main ${libname} ${apiname} ${opname} pthread ${TensorFlow_LIBRARY} rt deepmd_op_rocm coverage_config) else() - target_link_libraries(runUnitTests gtest gtest_main ${libname} ${apiname} ${opname} pthread ${TensorFlow_LIBRARY} coverage_config) + target_link_libraries(runUnitTests gtest gtest_main ${libname} ${apiname} ${opname} pthread ${TensorFlow_LIBRARY} rt coverage_config) endif() add_test( runUnitTests runUnitTests ) From 598af6770478a7c27063435ce5bfd59c85c9cf39 Mon Sep 17 00:00:00 2001 From: Yixiao Chen Date: Mon, 21 Jun 2021 22:14:49 -0400 Subject: [PATCH 3/3] add script to test cc without installing tf --- source/install/test_cc_local.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 source/install/test_cc_local.sh diff --git a/source/install/test_cc_local.sh b/source/install/test_cc_local.sh new file mode 100755 index 0000000000..1f28d7efa8 --- /dev/null +++ b/source/install/test_cc_local.sh @@ -0,0 +1,33 @@ +set -e + +#------------------ + +SCRIPT_PATH=$(dirname $(realpath -s $0)) +NPROC=$(nproc --all) + +#------------------ + +BUILD_TMP_DIR=${SCRIPT_PATH}/../build_tests +mkdir -p ${BUILD_TMP_DIR} +cd ${BUILD_TMP_DIR} +cmake ../lib/tests +make -j${NPROC} + +#------------------ +${BUILD_TMP_DIR}/runUnitTests + + +#------------------ + +echo "try to find tensorflow in ${tensorflow_root}" +BUILD_TMP_DIR=${SCRIPT_PATH}/../build_cc_tests +INSTALL_PREFIX=${SCRIPT_PATH}/../../dp +mkdir -p ${BUILD_TMP_DIR} +mkdir -p ${INSTALL_PREFIX} +cd ${BUILD_TMP_DIR} +cmake -DINSTALL_TENSORFLOW=FALSE -DTENSORFLOW_ROOT=${tensorflow_root} ../api_cc/tests +make -j${NPROC} + +#------------------ +cd ${SCRIPT_PATH}/../api_cc/tests +${BUILD_TMP_DIR}/runUnitTests