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
This commit is contained in:
Zlobin Vladimir 2022-12-27 17:44:46 +04:00 committed by GitHub
parent b8c92fce70
commit 055e34a77a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View File

@ -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()

View File

@ -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