Skip to content

Commit

Permalink
Install rules for static libraries case (openvinotoolkit#8384)
Browse files Browse the repository at this point in the history
* Proper cmake install for static libraries case

* Added an ability to skip template plugin

* Added install rules for VPU / GPU

* Install more libraries

* Fixed absolute TBB include paths

* Disable GNA

* Fixed issue with linker

* Some fixes

* Fixed linkage issues in tests

* Disabled some tests

* Updated CI pipelines

* Fixed Windows linkage

* Fixed custom_opset test for static casr

* Fixed CVS-70313

* Continue on error

* Fixed clanf-format

* Try to fix Windows linker

* Fixed compilation

* Disable samples

* Fixed samples build with THREADING=SEQ

* Fixed link error on Windows

* Fixed ieFuncTests

* Added static Azure CI

* Revert "Fixed link error on Windows"

This reverts commit 78cca36.

* Merge static and dynamic linux pipelines

* Fixed Azure
  • Loading branch information
ilya-lavrenov authored Nov 10, 2021
1 parent 91da09b commit 461f746
Show file tree
Hide file tree
Showing 60 changed files with 423 additions and 269 deletions.
18 changes: 18 additions & 0 deletions .ci/azure/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ resources:

jobs:
- job: Lin
strategy:
matrix:
Dynamic:
CMAKE_BUILD_SHARED_LIBS: 'ON'
Static:
CMAKE_BUILD_SHARED_LIBS: 'OFF'
maxParallel: 2

# About 150% of total time
timeoutInMinutes: 90

Expand Down Expand Up @@ -126,6 +134,9 @@ jobs:
-DVERBOSE_BUILD=ON
-DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
-DENABLE_PYTHON=ON
-DBUILD_SHARED_LIBS=$(CMAKE_BUILD_SHARED_LIBS)
-DENABLE_GNA=$(CMAKE_BUILD_SHARED_LIBS)
-DENABLE_CLDNN=$(CMAKE_BUILD_SHARED_LIBS)
-DPYTHON_EXECUTABLE=/usr/bin/python3.8
-DENABLE_WHEEL=ON
-DENABLE_TESTS=ON
Expand Down Expand Up @@ -183,10 +194,12 @@ jobs:
- script: $(INSTALL_DIR)/samples/cpp/build_samples.sh
workingDirectory: $(BUILD_SAMPLES_DIR)
displayName: 'Build cpp samples'
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')

- script: $(INSTALL_DIR)/samples/c/build_samples.sh
workingDirectory: $(BUILD_SAMPLES_DIR)
displayName: 'Build c samples'
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')

- script: rm -fr $(BUILD_DIR)
displayName: 'Clean build dir'
Expand All @@ -199,6 +212,7 @@ jobs:
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest -s $(INSTALL_TEST_DIR)/pyngraph --junitxml=TEST-Pyngraph.xml --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_zoo_models.py --ignore=$(INSTALL_TEST_DIR)/pyngraph/tests/test_onnx/test_backend.py
displayName: 'nGraph Python Bindings Tests'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: |
export MO_ROOT=$(INSTALL_DIR)/tools/model_optimizer
Expand All @@ -218,6 +232,7 @@ jobs:
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/tensorflow_tests --gtest_print_time=1 --gtest_output=xml:TEST-Tensorflow.xml
displayName: 'Tensorflow Frontend UT'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')

# . $(SETUPVARS) && python3 $(WORK_DIR)/gtest-parallel/gtest_parallel.py $(INSTALL_TEST_DIR)/InferenceEngineUnitTests --workers=16 --dump_json_test_results=InferenceEngineUnitTests.json --gtest_filter=*smoke* -- --gtest_print_time=1
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/InferenceEngineUnitTests --gtest_print_time=1 --gtest_output=xml:TEST-InferenceEngineUnitTests.xml
Expand All @@ -235,6 +250,7 @@ jobs:
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/gnaUnitTests --gtest_output=xml:TEST-gnaUnitTests.xml
displayName: 'GNA UT'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')

- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/vpuUnitTests --gtest_output=xml:TEST-vpuUnitTests.xml
displayName: 'VPU UT'
Expand All @@ -251,6 +267,7 @@ jobs:
- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/templateFuncTests --gtest_filter=*smoke* --gtest_output=xml:TEST-templateFuncTests.xml
displayName: 'TEMPLATE FuncTests'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')

- script: . $(SETUPVARS) && $(INSTALL_TEST_DIR)/cpuFuncTests --gtest_filter=*smoke* --gtest_print_time=1 --gtest_output=xml:TEST-cpuFuncTests.xml
displayName: 'CPU FuncTests'
Expand All @@ -270,6 +287,7 @@ jobs:
. $(SETUPVARS) -pyver 3.8 && python3 -m pytest --junitxml=TEST-PythonAPI.xml
displayName: 'Python API Tests'
continueOnError: false
condition: eq(variables['CMAKE_BUILD_SHARED_LIBS'], 'ON')
- script: |
. $(SETUPVARS)
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ include(cmake/test_model_zoo.cmake)
add_subdirectory(thirdparty)
add_subdirectory(openvino)
add_subdirectory(ngraph)
add_subdirectory(runtime)
add_subdirectory(inference-engine)
add_subdirectory(runtime)

# for Template plugin
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph_backend interpreter_backend)
Expand Down
9 changes: 9 additions & 0 deletions cmake/developer_package/IEDevScriptsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ endif()

# General flags

macro(ov_install_static_lib target comp)
if(NOT BUILD_SHARED_LIBS)
install(TARGETS ${target} EXPORT OpenVINOTargets
RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT ${comp}
ARCHIVE DESTINATION ${IE_CPACK_ARCHIVE_PATH} COMPONENT ${comp}
LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH} COMPONENT ${comp})
endif()
endmacro()

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

Expand Down
4 changes: 0 additions & 4 deletions cmake/developer_package/plugins/create_plugins_hpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,4 @@ endforeach()
set(IE_PLUGINS_MAP_DEFINITION "${IE_PLUGINS_MAP_DEFINITION}
};\n")


message("${IE_PLUGINS_DECLARATIONS}")
message("${IE_PLUGINS_MAP_DEFINITION}")

configure_file("${IE_PLUGINS_HPP_HEADER_IN}" "${IE_PLUGINS_HPP_HEADER}" @ONLY)
2 changes: 2 additions & 0 deletions cmake/developer_package/plugins/plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ function(ie_add_plugin)
target_compile_definitions(${IE_PLUGIN_NAME} PRIVATE
IE_CREATE_EXTENSION=CreateExtensionShared${IE_PLUGIN_DEVICE_NAME})
endif()
# install static plugins
ov_install_static_lib(${IE_PLUGIN_NAME} core)
endif()

ie_add_vs_version_file(NAME ${IE_PLUGIN_NAME}
Expand Down
137 changes: 71 additions & 66 deletions cmake/extra_modules.cmake
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

function(ie_generate_dev_package_config)
# dummy check that OpenCV is here
find_package(OpenCV QUIET)

set(all_dev_targets gflags ie_libraries)
foreach(component IN LISTS openvino_export_components)
export(TARGETS ${${component}} NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
list(APPEND all_dev_targets ${${component}})
endforeach()
add_custom_target(ie_dev_targets ALL DEPENDS ${all_dev_targets})

configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
INSTALL_DESTINATION share # not used
PATH_VARS "OpenVINO_SOURCE_DIR;gflags_BINARY_DIR"
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
@ONLY)
# dummy check that OpenCV is here
find_package(OpenCV QUIET)

set(all_dev_targets gflags ie_libraries)
foreach(component IN LISTS openvino_export_components)
export(TARGETS ${${component}} NAMESPACE IE::
APPEND FILE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
list(APPEND all_dev_targets ${${component}})
endforeach()
add_custom_target(ie_dev_targets ALL DEPENDS ${all_dev_targets})

configure_package_config_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineDeveloperPackageConfig.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
INSTALL_DESTINATION share # not used
PATH_VARS "OpenVINO_SOURCE_DIR;gflags_BINARY_DIR"
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

configure_file("${OpenVINO_SOURCE_DIR}/cmake/templates/InferenceEngineConfig-version.cmake.in"
"${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
@ONLY)
endfunction()

ie_generate_dev_package_config()
Expand All @@ -29,60 +32,62 @@ ie_generate_dev_package_config()
#

function(register_extra_modules)
# post export
openvino_developer_export_targets(COMPONENT inference_engine TARGETS inference_engine)
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph)
# post export
openvino_developer_export_targets(COMPONENT inference_engine TARGETS inference_engine)
openvino_developer_export_targets(COMPONENT ngraph TARGETS ngraph)

set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/runtime")
set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/runtime")

function(generate_fake_dev_package)
set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
file(REMOVE "${iedevconfig_file}")
function(generate_fake_dev_package)
set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
file(REMOVE "${iedevconfig_file}")

file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")

foreach(target IN LISTS ${openvino_export_components})
if(target)
file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
endif()
endforeach()
endfunction()
file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")

generate_fake_dev_package()
foreach(target IN LISTS ${openvino_export_components})
if(target)
file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
endif()
endforeach()
endfunction()

# automatically import plugins from the 'plugins' folder
file(GLOB local_extra_modules "runtime/plugins/*")
# add template plugin
list(APPEND local_extra_modules "${OpenVINO_SOURCE_DIR}/docs/template_plugin")
generate_fake_dev_package()

# detect where IE_EXTRA_MODULES contains folders with CMakeLists.txt
# other folders are supposed to have sub-folders with CMakeLists.txt
foreach(module_path IN LISTS IE_EXTRA_MODULES)
if(EXISTS "${module_path}/CMakeLists.txt")
list(APPEND extra_modules "${module_path}")
elseif(module_path)
file(GLOB extra_modules ${extra_modules} "${module_path}/*")
# automatically import plugins from the 'plugins' folder
file(GLOB local_extra_modules "runtime/plugins/*")
# add template plugin
if(ENABLE_TEMPLATE)
list(APPEND local_extra_modules "${OpenVINO_SOURCE_DIR}/docs/template_plugin")
endif()
endforeach()

# add each extra module
foreach(module_path IN LISTS extra_modules local_extra_modules)
if(module_path)
get_filename_component(module_name "${module_path}" NAME)
set(build_module ON)
if(NOT EXISTS "${module_path}/CMakeLists.txt") # if module is built not using cmake
set(build_module OFF)
endif()
if(NOT DEFINED BUILD_${module_name})
set(BUILD_${module_name} ${build_module} CACHE BOOL "Build ${module_name} extra module" FORCE)

# detect where IE_EXTRA_MODULES contains folders with CMakeLists.txt
# other folders are supposed to have sub-folders with CMakeLists.txt
foreach(module_path IN LISTS IE_EXTRA_MODULES)
if(EXISTS "${module_path}/CMakeLists.txt")
list(APPEND extra_modules "${module_path}")
elseif(module_path)
file(GLOB extra_modules ${extra_modules} "${module_path}/*")
endif()
if(BUILD_${module_name})
message(STATUS "Register ${module_name} to be built in build-modules/${module_name}")
add_subdirectory("${module_path}" "build-modules/${module_name}")
endforeach()

# add each extra module
foreach(module_path IN LISTS extra_modules local_extra_modules)
if(module_path)
get_filename_component(module_name "${module_path}" NAME)
set(build_module ON)
if(NOT EXISTS "${module_path}/CMakeLists.txt") # if module is built not using cmake
set(build_module OFF)
endif()
if(NOT DEFINED BUILD_${module_name})
set(BUILD_${module_name} ${build_module} CACHE BOOL "Build ${module_name} extra module" FORCE)
endif()
if(BUILD_${module_name})
message(STATUS "Register ${module_name} to be built in build-modules/${module_name}")
add_subdirectory("${module_path}" "build-modules/${module_name}")
endif()
endif()
endif()
endforeach()
endforeach()
endfunction()

register_extra_modules()
register_extra_modules()
4 changes: 3 additions & 1 deletion cmake/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ ie_option (ENABLE_MULTI "Enables Multi Device Plugin" ON)

ie_option (ENABLE_HETERO "Enables Hetero Device Plugin" ON)

ie_option (ENABLE_TEMPLATE "Enable template plugin" ON)

ie_dependent_option (ENABLE_VPU "vpu targeted plugins for inference engine" ON "NOT WINDOWS_PHONE;NOT WINDOWS_STORE" OFF)

ie_dependent_option (ENABLE_MYRIAD "myriad targeted plugin for inference engine" ON "ENABLE_VPU" OFF)
Expand Down Expand Up @@ -118,7 +120,7 @@ set(IE_EXTRA_MODULES "" CACHE STRING "Extra paths for extra modules to include i

ie_dependent_option(ENABLE_TBB_RELEASE_ONLY "Only Release TBB libraries are linked to the Inference Engine binaries" ON "THREADING MATCHES TBB;LINUX" OFF)

ie_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF)
ie_dependent_option (ENABLE_SYSTEM_PUGIXML "use the system copy of pugixml" OFF "BUILD_SHARED_LIBS" OFF)

ie_option (ENABLE_DEBUG_CAPS "enable OpenVINO debug capabilities at runtime" OFF)

Expand Down
12 changes: 12 additions & 0 deletions cmake/templates/OpenVINOConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,20 @@ if(THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO" AND NOT TBB_FOUND)
${_tbb_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)

set(install_tbbbind "@install_tbbbind@")
if(install_tbbbind)
set_and_check(_tbb_bind_dir "@PACKAGE_IE_TBBBIND_DIR@")
_ov_find_dependency(TBBBIND_2_5
PATHS ${_tbb_bind_dir}
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
set_target_properties(${TBBBIND_2_5_IMPORTED_TARGETS} PROPERTIES IMPORTED_GLOBAL ON)
endif()
endif()

_ov_find_dependency(Threads)

if(NOT TARGET inference_engine)
set(_ov_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/OpenVINOTargets.cmake")
Expand Down
3 changes: 3 additions & 0 deletions cmake/toolchains/ia32.linux.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ macro(_set_if_not_defined var val)
endif()
endmacro()

# for ittapi
_set_if_not_defined(FORCE_32 ON)

# need libusb 32-bits version
_set_if_not_defined(ENABLE_VPU OFF)
14 changes: 10 additions & 4 deletions docs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ if(NOT ENABLE_DOCKER)
add_subdirectory(template_extension)

set(all_docs_targets
ie_docs_snippets
template_extension templatePlugin templateFuncTests)
ie_docs_snippets templateFuncTests
template_extension template_ov_extension templatePlugin)
foreach(target_name IN LISTS all_docs_targets)
if(TARGET ${target_name})
set_target_properties(${target_name} PROPERTIES FOLDER docs)
Expand All @@ -36,8 +36,14 @@ if(NOT ENABLE_DOCKER)

# install

install(TARGETS templatePlugin template_extension template_ov_extension
LIBRARY DESTINATION ${IE_CPACK_RUNTIME_PATH} COMPONENT tests EXCLUDE_FROM_ALL)
foreach(target templatePlugin template_extension template_ov_extension)
if(TARGET ${target})
install(TARGETS ${target}
LIBRARY DESTINATION ${IE_CPACK_RUNTIME_PATH}
COMPONENT tests
EXCLUDE_FROM_ALL)
endif()
endforeach()
endif()

set(OMZ_DOCS_DIR "" CACHE PATH "Path to open_model_zoo documentation")
Expand Down
12 changes: 2 additions & 10 deletions docs/template_plugin/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,5 @@ set_target_properties(${TARGET_NAME} PROPERTIES INTERPROCEDURAL_OPTIMIZATION_REL
# POSSIBLE_PLUGINS ${TARGET_NAME})
# [cmake:plugin]

# ATTENTION: uncomment to install component
# install

# set(component_name template)
# ie_cpack_add_component(${component_name} REQUIRED)

# install(TARGETS ${TARGET_NAME}
# RUNTIME DESTINATION ${IE_CPACK_RUNTIME_PATH}
# LIBRARY DESTINATION ${IE_CPACK_LIBRARY_PATH}
# COMPONENT ${component_name})
ov_install_static_lib(ngraph_backend ngraph)
ov_install_static_lib(interpreter_backend ngraph)
7 changes: 5 additions & 2 deletions inference-engine/cmake/ie_parallel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ function(set_ie_threading_interface_for TARGET_NAME)
if(TARGET ${library})
get_target_property(include_directories ${library} INTERFACE_INCLUDE_DIRECTORIES)
if(include_directories)
target_include_directories(${TARGET_NAME} SYSTEM BEFORE ${LINK_TYPE} ${include_directories})
foreach(include_directory IN LISTS include_directories)
target_include_directories(${TARGET_NAME} SYSTEM BEFORE
${LINK_TYPE} $<BUILD_INTERFACE:${include_directory}>)
endforeach()
endif()
endif()
endforeach()
Expand Down Expand Up @@ -178,6 +181,6 @@ function(set_ie_threading_interface_for TARGET_NAME)

if (NOT THREADING STREQUAL "SEQ")
find_package(Threads REQUIRED)
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} ${CMAKE_THREAD_LIBS_INIT})
ie_target_link_libraries(${TARGET_NAME} ${LINK_TYPE} Threads::Threads)
endif()
endfunction(set_ie_threading_interface_for)
Loading

0 comments on commit 461f746

Please sign in to comment.