From 055e34a77aabeac160d82b318574ade5dbddfc64 Mon Sep 17 00:00:00 2001 From: Zlobin Vladimir Date: Tue, 27 Dec 2022 17:44:46 +0400 Subject: [PATCH] Allow running samples CMakeLists.txt as stand alone (#14826) * Allow running samples CMakeLists.txt as stand alone * Don't add cnpy twice * Fix binary path --- samples/cpp/benchmark_app/CMakeLists.txt | 7 +++++++ samples/cpp/speech_sample/CMakeLists.txt | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/samples/cpp/benchmark_app/CMakeLists.txt b/samples/cpp/benchmark_app/CMakeLists.txt index 7f40d1fabb7..385b2ff26fa 100644 --- a/samples/cpp/benchmark_app/CMakeLists.txt +++ b/samples/cpp/benchmark_app/CMakeLists.txt @@ -59,10 +59,17 @@ if(NOT TARGET nlohmann_json::nlohmann_json) if(NOT nlohmann_json_FOUND) if(EXISTS "${Samples_SOURCE_DIR}/thirdparty/nlohmann_json") + # OpenVINO package puts thirdparty to samples dir # suppress shadowing names warning set(JSON_SystemInclude ON CACHE BOOL "" FORCE) add_subdirectory("${Samples_SOURCE_DIR}/thirdparty/nlohmann_json" "${Samples_BINARY_DIR}/thirdparty/nlohmann_json" EXCLUDE_FROM_ALL) + elseif(EXISTS "${Samples_SOURCE_DIR}../../thirdparty/nlohmann_json") + # Allow running samples CMakeLists.txt as stand alone from openvino sources + # suppress shadowing names warning + set(JSON_SystemInclude ON CACHE BOOL "" FORCE) + add_subdirectory("${Samples_SOURCE_DIR}../../thirdparty/nlohmann_json" + "${Samples_BINARY_DIR}/thirdparty/nlohmann_json" EXCLUDE_FROM_ALL) else() message(FATAL_ERROR "Failed to find / build nlohmann_json library") endif() diff --git a/samples/cpp/speech_sample/CMakeLists.txt b/samples/cpp/speech_sample/CMakeLists.txt index 5ffaae4af46..ad15ce77318 100644 --- a/samples/cpp/speech_sample/CMakeLists.txt +++ b/samples/cpp/speech_sample/CMakeLists.txt @@ -25,14 +25,24 @@ if(NOT TARGET zlib::zlib) if(zlib_FOUND) message(STATUS "${PKG_CONFIG_EXECUTABLE}: zlib (${zlib_VERSION}) is found at ${zlib_PREFIX}") elseif(EXISTS "${Samples_SOURCE_DIR}/thirdparty/zlib") + # OpenVINO package puts thirdparty to samples dir add_subdirectory("${Samples_SOURCE_DIR}/thirdparty/zlib" "${Samples_BINARY_DIR}/thirdparty/zlib" EXCLUDE_FROM_ALL) + elseif(EXISTS "${Samples_SOURCE_DIR}/thirdparty/zlib") + # Allow running samples CMakeLists.txt as stand alone from openvino sources + add_subdirectory("${Samples_SOURCE_DIR}/../../thirdparty/zlib" + "${Samples_BINARY_DIR}/thirdparty/zlib" EXCLUDE_FROM_ALL) endif() endif() if(EXISTS "${Samples_SOURCE_DIR}/thirdparty/cnpy") + # OpenVINO package puts thirdparty to samples dir add_subdirectory("${Samples_SOURCE_DIR}/thirdparty/cnpy" "${Samples_BINARY_DIR}/thirdparty/cnpy" EXCLUDE_FROM_ALL) +elseif(EXISTS "${Samples_SOURCE_DIR}/../../thirdparty/cnpy" AND NOT TARGET cnpy) + # Allow running samples CMakeLists.txt as stand alone from openvino sources + add_subdirectory("${Samples_SOURCE_DIR}/../../thirdparty/cnpy" + "${Samples_BINARY_DIR}/thirdparty/cnpy" EXCLUDE_FROM_ALL) endif() # add sample