From ded7eeb03398a0bf978a11a0ac25e01a2b124b89 Mon Sep 17 00:00:00 2001 From: Maik Riechert Date: Mon, 29 Apr 2019 20:58:20 +0100 Subject: [PATCH] make builds more robust (#906) (#932) --- cmake/onnx/CMakeLists.txt | 4 ++-- cmake/onnxruntime_codegen.cmake | 2 +- cmake/onnxruntime_common.cmake | 4 +++- cmake/onnxruntime_framework.cmake | 2 +- cmake/onnxruntime_graph.cmake | 4 ++-- cmake/onnxruntime_optimizer.cmake | 2 +- cmake/onnxruntime_providers.cmake | 16 ++++++++-------- cmake/onnxruntime_python.cmake | 16 +++++++++------- cmake/onnxruntime_session.cmake | 2 +- cmake/onnxruntime_unittests.cmake | 29 ++++++++++++++++++----------- cmake/onnxruntime_util.cmake | 2 +- 11 files changed, 47 insertions(+), 36 deletions(-) diff --git a/cmake/onnx/CMakeLists.txt b/cmake/onnx/CMakeLists.txt index 414f899981..3c7e6b3d70 100644 --- a/cmake/onnx/CMakeLists.txt +++ b/cmake/onnx/CMakeLists.txt @@ -11,12 +11,12 @@ endif() # Cpp Tests were added and they require googletest # since we have our own copy, try using that set(ONNX_SOURCE_ROOT ${PROJECT_SOURCE_DIR}/external/onnx) -file(GLOB_RECURSE onnx_src +file(GLOB_RECURSE onnx_src CONFIGURE_DEPENDS "${ONNX_SOURCE_ROOT}/onnx/*.h" "${ONNX_SOURCE_ROOT}/onnx/*.cc" ) -file(GLOB_RECURSE onnx_exclude_src +file(GLOB_RECURSE onnx_exclude_src CONFIGURE_DEPENDS "${ONNX_SOURCE_ROOT}/onnx/py_utils.h" "${ONNX_SOURCE_ROOT}/onnx/proto_utils.h" "${ONNX_SOURCE_ROOT}/onnx/backend/test/cpp/*" diff --git a/cmake/onnxruntime_codegen.cmake b/cmake/onnxruntime_codegen.cmake index b43afa3029..d63d367f2b 100644 --- a/cmake/onnxruntime_codegen.cmake +++ b/cmake/onnxruntime_codegen.cmake @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB_RECURSE onnxruntime_codegen_tvm_srcs +file(GLOB_RECURSE onnxruntime_codegen_tvm_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/codegen/tvm/*.h" "${ONNXRUNTIME_ROOT}/core/codegen/tvm/*.cc" ) diff --git a/cmake/onnxruntime_common.cmake b/cmake/onnxruntime_common.cmake index 573322bad5..955b82cc8c 100644 --- a/cmake/onnxruntime_common.cmake +++ b/cmake/onnxruntime_common.cmake @@ -32,7 +32,9 @@ else() ) endif() -file(GLOB onnxruntime_common_src ${onnxruntime_common_src_patterns}) +file(GLOB onnxruntime_common_src CONFIGURE_DEPENDS + ${onnxruntime_common_src_patterns} + ) source_group(TREE ${REPO_ROOT} FILES ${onnxruntime_common_src}) diff --git a/cmake/onnxruntime_framework.cmake b/cmake/onnxruntime_framework.cmake index 488e4c2d0d..174f07ffc0 100644 --- a/cmake/onnxruntime_framework.cmake +++ b/cmake/onnxruntime_framework.cmake @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB_RECURSE onnxruntime_framework_srcs +file(GLOB_RECURSE onnxruntime_framework_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_INCLUDE_DIR}/core/framework/*.h" "${ONNXRUNTIME_ROOT}/core/framework/*.h" "${ONNXRUNTIME_ROOT}/core/framework/*.cc" diff --git a/cmake/onnxruntime_graph.cmake b/cmake/onnxruntime_graph.cmake index 5b2ac8988f..366eadf680 100644 --- a/cmake/onnxruntime_graph.cmake +++ b/cmake/onnxruntime_graph.cmake @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB_RECURSE onnxruntime_graph_src +file(GLOB_RECURSE onnxruntime_graph_src CONFIGURE_DEPENDS "${ONNXRUNTIME_INCLUDE_DIR}/core/graph/*.h" "${ONNXRUNTIME_ROOT}/core/graph/*.h" "${ONNXRUNTIME_ROOT}/core/graph/*.cc" @@ -14,7 +14,7 @@ if (onnxruntime_DISABLE_CONTRIB_OPS) ) endif() -file(GLOB_RECURSE onnxruntime_ir_defs_src +file(GLOB_RECURSE onnxruntime_ir_defs_src CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/defs/*.cc" ) diff --git a/cmake/onnxruntime_optimizer.cmake b/cmake/onnxruntime_optimizer.cmake index 4bf0af2873..c9a09dbce7 100644 --- a/cmake/onnxruntime_optimizer.cmake +++ b/cmake/onnxruntime_optimizer.cmake @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB onnxruntime_optimizer_srcs +file(GLOB onnxruntime_optimizer_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/optimizer/*.h" "${ONNXRUNTIME_ROOT}/core/optimizer/*.cc" ) diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index b8f3e1100b..15ad19948e 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -1,19 +1,19 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB_RECURSE onnxruntime_providers_srcs +file(GLOB_RECURSE onnxruntime_providers_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/cpu/*.h" "${ONNXRUNTIME_ROOT}/core/providers/cpu/*.cc" ) -file(GLOB_RECURSE onnxruntime_contrib_ops_srcs +file(GLOB_RECURSE onnxruntime_contrib_ops_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/contrib_ops/*.h" "${ONNXRUNTIME_ROOT}/contrib_ops/*.cc" "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/*.h" "${ONNXRUNTIME_ROOT}/contrib_ops/cpu/*.cc" ) -file(GLOB onnxruntime_providers_common_srcs +file(GLOB onnxruntime_providers_common_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/*.h" "${ONNXRUNTIME_ROOT}/core/providers/*.cc" ) @@ -55,11 +55,11 @@ set_target_properties(onnxruntime_providers PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(onnxruntime_providers PROPERTIES FOLDER "ONNXRuntime") if (onnxruntime_USE_CUDA) - file(GLOB_RECURSE onnxruntime_providers_cuda_cc_srcs + file(GLOB_RECURSE onnxruntime_providers_cuda_cc_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/cuda/*.h" "${ONNXRUNTIME_ROOT}/core/providers/cuda/*.cc" ) - file(GLOB_RECURSE onnxruntime_providers_cuda_cu_srcs + file(GLOB_RECURSE onnxruntime_providers_cuda_cu_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/cuda/*.cu" "${ONNXRUNTIME_ROOT}/core/providers/cuda/*.cuh" ) @@ -95,7 +95,7 @@ if (onnxruntime_USE_CUDA) endif() if (onnxruntime_USE_MKLDNN) - file(GLOB_RECURSE onnxruntime_providers_mkldnn_cc_srcs + file(GLOB_RECURSE onnxruntime_providers_mkldnn_cc_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/mkldnn/*.h" "${ONNXRUNTIME_ROOT}/core/providers/mkldnn/*.cc" ) @@ -159,7 +159,7 @@ if (onnxruntime_USE_TENSORRT) set(trt_link_libs cudnn ${CMAKE_DL_LIBS} ${TENSORRT_LIBRARY}) set(onnxparser_link_libs nvonnxparser_static nvonnxparser_plugin) - file(GLOB_RECURSE onnxruntime_providers_tensorrt_cc_srcs + file(GLOB_RECURSE onnxruntime_providers_tensorrt_cc_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/tensorrt/*.h" "${ONNXRUNTIME_ROOT}/core/providers/tensorrt/*.cc" ) @@ -182,7 +182,7 @@ endif() if (onnxruntime_USE_NGRAPH) include_directories("${CMAKE_CURRENT_BINARY_DIR}/onnx") - file(GLOB_RECURSE onnxruntime_providers_ngraph_cc_srcs + file(GLOB_RECURSE onnxruntime_providers_ngraph_cc_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/providers/ngraph/*.h" "${ONNXRUNTIME_ROOT}/core/providers/ngraph/*.cc" ) diff --git a/cmake/onnxruntime_python.cmake b/cmake/onnxruntime_python.cmake index ace16b1b87..6f2d325090 100644 --- a/cmake/onnxruntime_python.cmake +++ b/cmake/onnxruntime_python.cmake @@ -36,7 +36,9 @@ set(onnxruntime_pybind_srcs_pattern "${ONNXRUNTIME_ROOT}/python/*.h" ) -file(GLOB onnxruntime_pybind_srcs ${onnxruntime_pybind_srcs_pattern}) +file(GLOB onnxruntime_pybind_srcs CONFIGURE_DEPENDS + ${onnxruntime_pybind_srcs_pattern} + ) #TODO(): enable cuda and test it add_library(onnxruntime_pybind11_state MODULE ${onnxruntime_pybind_srcs}) @@ -114,22 +116,22 @@ else() set_target_properties(onnxruntime_pybind11_state PROPERTIES SUFFIX ".so") endif() -file(GLOB onnxruntime_backend_srcs +file(GLOB onnxruntime_backend_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/python/backend/*.py" ) -file(GLOB onnxruntime_python_srcs +file(GLOB onnxruntime_python_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/python/*.py" ) -file(GLOB onnxruntime_python_test_srcs +file(GLOB onnxruntime_python_test_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/test/python/*.py" ) -file(GLOB onnxruntime_python_tools_srcs +file(GLOB onnxruntime_python_tools_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/python/tools/*.py" ) -file(GLOB onnxruntime_python_datasets_srcs +file(GLOB onnxruntime_python_datasets_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/python/datasets/*.py" ) -file(GLOB onnxruntime_python_datasets_data +file(GLOB onnxruntime_python_datasets_data CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/python/datasets/*.pb" "${ONNXRUNTIME_ROOT}/python/datasets/*.onnx" ) diff --git a/cmake/onnxruntime_session.cmake b/cmake/onnxruntime_session.cmake index 1d55b7d5e1..1824ed1283 100644 --- a/cmake/onnxruntime_session.cmake +++ b/cmake/onnxruntime_session.cmake @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB onnxruntime_session_srcs +file(GLOB onnxruntime_session_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_INCLUDE_DIR}/core/session/*.h" "${ONNXRUNTIME_ROOT}/core/session/*.h" "${ONNXRUNTIME_ROOT}/core/session/*.cc" diff --git a/cmake/onnxruntime_unittests.cmake b/cmake/onnxruntime_unittests.cmake index d0e8318b4c..c3e8083d00 100644 --- a/cmake/onnxruntime_unittests.cmake +++ b/cmake/onnxruntime_unittests.cmake @@ -68,24 +68,24 @@ endfunction(AddTest) #Use onnxruntime_add_include_to_target or target_link_libraries, so that compile definitions #can propagate correctly. -file(GLOB onnxruntime_test_utils_src +file(GLOB onnxruntime_test_utils_src CONFIGURE_DEPENDS "${TEST_SRC_DIR}/util/include/*.h" "${TEST_SRC_DIR}/util/*.cc" ) -file(GLOB onnxruntime_test_common_src +file(GLOB onnxruntime_test_common_src CONFIGURE_DEPENDS "${TEST_SRC_DIR}/common/*.cc" "${TEST_SRC_DIR}/common/*.h" "${TEST_SRC_DIR}/common/logging/*.cc" "${TEST_SRC_DIR}/common/logging/*.h" ) -file(GLOB onnxruntime_test_ir_src +file(GLOB onnxruntime_test_ir_src CONFIGURE_DEPENDS "${TEST_SRC_DIR}/ir/*.cc" "${TEST_SRC_DIR}/ir/*.h" ) -file(GLOB onnxruntime_test_optimizer_src +file(GLOB onnxruntime_test_optimizer_src CONFIGURE_DEPENDS "${TEST_SRC_DIR}/optimizer/*.cc" "${TEST_SRC_DIR}/optimizer/*.h" ) @@ -118,14 +118,15 @@ if(NOT onnxruntime_DISABLE_CONTRIB_OPS) "${TEST_SRC_DIR}/contrib_ops/*.cc") endif() -file(GLOB onnxruntime_test_providers_src ${onnxruntime_test_providers_src_patterns}) -file(GLOB_RECURSE onnxruntime_test_providers_cpu_src +file(GLOB onnxruntime_test_providers_src CONFIGURE_DEPENDS + ${onnxruntime_test_providers_src_patterns}) +file(GLOB_RECURSE onnxruntime_test_providers_cpu_src CONFIGURE_DEPENDS "${TEST_SRC_DIR}/providers/cpu/*" ) list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_cpu_src}) if (onnxruntime_USE_NGRAPH) - file(GLOB_RECURSE onnxruntime_test_providers_ngraph_src + file(GLOB_RECURSE onnxruntime_test_providers_ngraph_src CONFIGURE_DEPENDS "${TEST_SRC_DIR}/providers/ngraph/*" ) list(APPEND onnxruntime_test_providers_src ${onnxruntime_test_providers_ngraph_src}) @@ -183,7 +184,7 @@ if(onnxruntime_USE_NGRAPH) list(APPEND onnxruntime_test_providers_dependencies onnxruntime_providers_ngraph) endif() -file(GLOB_RECURSE onnxruntime_test_tvm_src +file(GLOB_RECURSE onnxruntime_test_tvm_src CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/test/tvm/*.h" "${ONNXRUNTIME_ROOT}/test/tvm/*.cc" ) @@ -228,7 +229,9 @@ if(WIN32) endif() endif() -file(GLOB onnxruntime_test_framework_src ${onnxruntime_test_framework_src_patterns}) +file(GLOB onnxruntime_test_framework_src CONFIGURE_DEPENDS + ${onnxruntime_test_framework_src_patterns} + ) #with auto initialize onnxruntime add_library(onnxruntime_test_utils_for_framework ${onnxruntime_test_utils_src}) @@ -261,7 +264,9 @@ if (SingleUnitTestProject) endif() # we can only have one 'main', so remove them all and add back the providers test_main as it sets # up everything we need for all tests - file(GLOB_RECURSE test_mains "${TEST_SRC_DIR}/*/test_main.cc") + file(GLOB_RECURSE test_mains CONFIGURE_DEPENDS + "${TEST_SRC_DIR}/*/test_main.cc" + ) list(REMOVE_ITEM all_tests ${test_mains}) list(APPEND all_tests "${TEST_SRC_DIR}/providers/test_main.cc") @@ -474,7 +479,9 @@ else () "${onnxruntime_perf_test_src_dir}/posix/*.h" ) endif() -file(GLOB onnxruntime_perf_test_src ${onnxruntime_perf_test_src_patterns}) +file(GLOB onnxruntime_perf_test_src CONFIGURE_DEPENDS + ${onnxruntime_perf_test_src_patterns} + ) add_executable(onnxruntime_perf_test ${onnxruntime_perf_test_src} ${ONNXRUNTIME_ROOT}/core/framework/path_lib.cc) target_include_directories(onnxruntime_perf_test PRIVATE ${onnx_test_runner_src_dir} ${ONNXRUNTIME_ROOT} diff --git a/cmake/onnxruntime_util.cmake b/cmake/onnxruntime_util.cmake index 1b18a18998..a8b611d7c9 100644 --- a/cmake/onnxruntime_util.cmake +++ b/cmake/onnxruntime_util.cmake @@ -1,7 +1,7 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. -file(GLOB_RECURSE onnxruntime_util_srcs +file(GLOB_RECURSE onnxruntime_util_srcs CONFIGURE_DEPENDS "${ONNXRUNTIME_ROOT}/core/util/*.h" "${ONNXRUNTIME_ROOT}/core/util/*.cc" )