From 5cc08367b21e0e6344762df95b460d854d03b1a1 Mon Sep 17 00:00:00 2001 From: Andrey Somsikov Date: Mon, 7 Dec 2020 12:56:37 +0300 Subject: [PATCH] Build time_tests with OpenVINO install (#3484) --- tests/time_tests/CMakeLists.txt | 5 ++- tests/time_tests/README.md | 14 ++++++-- .../src/timetests_helper/CMakeLists.txt | 36 +++++++++++++++++-- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/tests/time_tests/CMakeLists.txt b/tests/time_tests/CMakeLists.txt index f4b4c670387..4175c7f5503 100644 --- a/tests/time_tests/CMakeLists.txt +++ b/tests/time_tests/CMakeLists.txt @@ -9,6 +9,9 @@ if (CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE "Release") endif() -find_package(InferenceEngineDeveloperPackage REQUIRED) +find_package(InferenceEngineDeveloperPackage QUIET) +if (NOT InferenceEngineDeveloperPackage_FOUND) + find_package(InferenceEngine REQUIRED) +endif() add_subdirectory(src) diff --git a/tests/time_tests/README.md b/tests/time_tests/README.md index a68b2ff4814..282f0d8394c 100644 --- a/tests/time_tests/README.md +++ b/tests/time_tests/README.md @@ -6,19 +6,27 @@ pipelines and calcuates the average execution time. ## Prerequisites -To build the time tests, you need to have the `build` folder, which is created -when you configure and build OpenVINO™. +To build the time tests, you need to have OpenVINO™ installed or build from source. ## Measure Time -To build and run the tests, open a terminal and run the commands below: +To build and run the tests, open a terminal, set OpenVINO™ environment and run +the commands below: 1. Build tests: ``` bash mkdir build && cd build +cmake .. && make time_tests +``` + +If you don't have OpenVINO™ installed you need to have the `build` folder, which +is created when you configure and build OpenVINO™ from sources: + +``` bash cmake .. -DInferenceEngineDeveloperPackage_DIR=$(realpath ../../../build) && make time_tests ``` + 2. Run test: ``` bash ./scripts/run_timetest.py ../../bin/intel64/Release/timetest_infer -m model.xml -d CPU diff --git a/tests/time_tests/src/timetests_helper/CMakeLists.txt b/tests/time_tests/src/timetests_helper/CMakeLists.txt index ba5760edecf..072805bd42a 100644 --- a/tests/time_tests/src/timetests_helper/CMakeLists.txt +++ b/tests/time_tests/src/timetests_helper/CMakeLists.txt @@ -4,10 +4,40 @@ set (TARGET_NAME "timetests_helper") -find_package(gflags REQUIRED) - file (GLOB SRC *.cpp) add_library(${TARGET_NAME} STATIC ${SRC}) target_include_directories(${TARGET_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/include") -target_link_libraries(${TARGET_NAME} gflags) +find_package(gflags QUIET) +if (gflags_FOUND) + set(GFLAGS_LIBRARIES gflags) # use gflags from developer package +else() + include(ExternalProject) + find_package(Threads) + set(gflags_PREFIX ${CMAKE_BINARY_DIR}/external/gflags-prefix) + set(gflags_INSTALL ${CMAKE_BINARY_DIR}/external/gflags-install) + set(gflags_LIB ${gflags_INSTALL}/lib/libgflags.a) + + ExternalProject_Add( + gflags + PREFIX ${gflags_PREFIX} + GIT_REPOSITORY "https://github.com/gflags/gflags.git" + GIT_TAG "v2.2.2" + UPDATE_COMMAND "" + INSTALL_DIR ${gflags_INSTALL} + CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} + CMAKE_GENERATOR ${CMAKE_GENERATOR} + CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM} + CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET} + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${gflags_INSTALL} + EXCLUDE_FROM_ALL TRUE + BUILD_BYPRODUCTS ${gflags_LIB} + LOG_DOWNLOAD 1 + LOG_INSTALL 1 + ) + set(GFLAGS_LIBRARIES ${gflags_LIB} ${CMAKE_THREAD_LIBS_INIT}) + add_dependencies(${TARGET_NAME} gflags) + target_include_directories(${TARGET_NAME} PRIVATE "${gflags_INSTALL}/include") +endif() + +target_link_libraries(${TARGET_NAME} ${GFLAGS_LIBRARIES})