Skip to content

Commit 0df3444

Browse files
committed
Enable linking against OV python package
1 parent a2a1849 commit 0df3444

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

model_api/cpp/CMakeLists.txt

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ if(NOT GENERATOR_IS_MULTI_CONFIG_VAR AND NOT DEFINED CMAKE_BUILD_TYPE)
1313
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel ...")
1414
endif()
1515

16-
project(model_api)
16+
set(model_api_VERSION 0.0.0)
17+
18+
project(model_api
19+
VERSION ${model_api_VERSION}
20+
DESCRIPTION "OpenVINO Vision API"
21+
HOMEPAGE_URL "https://github.com/openvinotoolkit/model_api/"
22+
LANGUAGES CXX C)
1723

1824
if(WIN32)
1925
if(NOT "${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
@@ -23,10 +29,21 @@ if(WIN32)
2329
add_definitions(-DNOMINMAX)
2430
endif()
2531

26-
set(model_api_VERSION 0.0.0)
27-
2832
find_package(OpenCV REQUIRED COMPONENTS core imgproc)
29-
find_package(OpenVINO REQUIRED COMPONENTS Runtime)
33+
34+
# Looking for OpenVINO in the python distribution. It doesn't work for cross-compiling build
35+
if(NOT CMAKE_CROSSCOMPILING)
36+
find_package(Python3 REQUIRED)
37+
execute_process(
38+
COMMAND ${Python3_EXECUTABLE} -c "from openvino.utils import get_cmake_path; print(get_cmake_path(), end='')"
39+
OUTPUT_VARIABLE OpenVINO_DIR_PY
40+
ERROR_QUIET
41+
)
42+
endif()
43+
44+
find_package(OpenVINO REQUIRED
45+
COMPONENTS Runtime Threading
46+
HINTS "${OpenVINO_DIR_PY}")
3047

3148
include(FetchContent)
3249
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz)

0 commit comments

Comments
 (0)