Files
openvino/CMakeLists.txt
T

156 lines
5.6 KiB
CMake
Raw Normal View History

2023-01-16 11:02:17 +04:00
# Copyright (C) 2018-2023 Intel Corporation
2020-02-11 22:48:49 +03:00
# SPDX-License-Identifier: Apache-2.0
#
if(DEFINED BUILD_SHARED_LIBS AND NOT BUILD_SHARED_LIBS)
# 3.17: 'target_link_libraries' does not work correctly when called from
2022-03-31 18:05:59 +03:00
# different directory where 'add_library' is called: CMake generates
# incorrect OpenVINOConfig.cmake in this case
# 3.18: add_library cannot create ALIAS for non-GLOBAL targets
cmake_minimum_required(VERSION 3.18)
else()
if(CPACK_GENERATOR STREQUAL "DEB")
# we have to use CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS variable
cmake_minimum_required(VERSION 3.20)
else()
2022-08-23 01:39:23 +04:00
# default choice
cmake_minimum_required(VERSION 3.13)
endif()
endif()
2020-02-11 22:48:49 +03:00
2023-03-30 21:01:41 +04:00
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW) # Enables use of MSVC_RUNTIME_LIBRARY
endif()
project(OpenVINO DESCRIPTION "OpenVINO toolkit")
2020-02-11 22:48:49 +03:00
2020-12-22 18:44:59 +03:00
find_package(IEDevScripts REQUIRED
PATHS "${OpenVINO_SOURCE_DIR}/cmake/developer_package"
2020-12-22 18:44:59 +03:00
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
2020-02-11 22:48:49 +03:00
2020-12-22 18:44:59 +03:00
include(CTest)
include(cmake/features.cmake)
2020-02-11 22:48:49 +03:00
2020-10-05 23:37:50 +03:00
# These options are shared with 3rdparty plugins by means of developer package
2020-12-22 18:44:59 +03:00
include(cmake/dependencies.cmake)
2020-02-11 22:48:49 +03:00
2021-06-24 13:14:04 +03:00
if(ENABLE_COVERAGE)
include(cmake/coverage.cmake)
endif()
2020-02-11 22:48:49 +03:00
# resolving dependencies for the project
2021-11-28 21:36:24 +03:00
message (STATUS "CMAKE_VERSION ......................... " ${CMAKE_VERSION})
2021-09-02 10:03:04 +03:00
message (STATUS "OpenVINO_SOURCE_DIR ................... " ${OpenVINO_SOURCE_DIR})
2022-02-25 15:47:21 +03:00
message (STATUS "OpenVINO_BINARY_DIR ................... " ${OpenVINO_BINARY_DIR})
2020-02-11 22:48:49 +03:00
message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
message (STATUS "CPACK_GENERATOR ....................... " ${CPACK_GENERATOR})
2020-02-11 22:48:49 +03:00
message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
2021-11-27 14:58:24 +03:00
message (STATUS "CMAKE_CXX_COMPILER_ID ................. " ${CMAKE_CXX_COMPILER_ID})
2023-03-05 10:46:53 +04:00
if(OV_GENERATOR_MULTI_CONFIG)
string(REPLACE ";" " " config_types "${CMAKE_CONFIGURATION_TYPES}")
message (STATUS "CMAKE_CONFIGURATION_TYPES ............. " ${config_types})
unset(config_types)
if(CMAKE_GENERATOR MATCHES "^Ninja Multi-Config$")
message (STATUS "CMAKE_DEFAULT_BUILD_TYPE .............. " ${CMAKE_DEFAULT_BUILD_TYPE})
endif()
else()
message (STATUS "CMAKE_BUILD_TYPE ...................... " ${CMAKE_BUILD_TYPE})
endif()
if(CMAKE_GENERATOR_PLATFORM)
message (STATUS "CMAKE_GENERATOR_PLATFORM .............. " ${CMAKE_GENERATOR_PLATFORM})
endif()
if(CMAKE_GENERATOR_TOOLSET)
message (STATUS "CMAKE_GENERATOR_TOOLSET ............... " ${CMAKE_GENERATOR_TOOLSET})
endif()
if(CMAKE_TOOLCHAIN_FILE)
message (STATUS "CMAKE_TOOLCHAIN_FILE .................. " ${CMAKE_TOOLCHAIN_FILE})
endif()
2023-05-17 00:47:55 +04:00
if(NOT OV_GLIBC_VERSION VERSION_EQUAL 0.0)
2023-03-05 10:46:53 +04:00
message (STATUS "GLIBC_VERSION ......................... " ${OV_GLIBC_VERSION})
endif()
2020-02-11 22:48:49 +03:00
2023-07-18 19:54:00 +04:00
# remove file with exported targets to force its regeneration
2022-02-25 15:47:21 +03:00
file(REMOVE "${CMAKE_BINARY_DIR}/ngraphTargets.cmake")
2021-05-07 11:57:51 +03:00
file(REMOVE "${CMAKE_BINARY_DIR}/InferenceEngineTargets.cmake")
2021-09-10 15:31:27 +03:00
file(REMOVE "${CMAKE_BINARY_DIR}/OpenVINOTargets.cmake")
2023-07-18 19:54:00 +04:00
# remove exported developer targets to force its regeneration
macro(ov_clean_dev_targets)
foreach(component IN LISTS openvino_export_components)
file(REMOVE "${CMAKE_BINARY_DIR}/${component}_dev_targets.cmake")
file(REMOVE "${CMAKE_BINARY_DIR}/ov_${component}_dev_targets.cmake")
unset(${component} CACHE)
endforeach()
unset(openvino_export_components CACHE)
unset(openvino_installed_targets CACHE)
endmacro()
ov_clean_dev_targets()
2020-02-11 22:48:49 +03:00
2020-10-05 23:37:50 +03:00
#
# Build
#
function(openvino_developer_export_targets)
2020-12-22 18:44:59 +03:00
cmake_parse_arguments(EXPORT "" "COMPONENT" "TARGETS" ${ARGN})
if(EXPORT_UNPARSED_ARGUMENTS)
message(FATAL_ERROR "openvino_developer_export_targets has unparsed arguments: ${EXPORT_UNPARSED_ARGUMENTS}")
endif()
set(${EXPORT_COMPONENT} "${${EXPORT_COMPONENT}};${EXPORT_TARGETS}")
# to allow exporting of aliased targets with the original names
2020-12-22 18:44:59 +03:00
foreach(target_name IN LISTS ${EXPORT_COMPONENT})
if(TARGET "${target_name}")
get_target_property(original_name ${target_name} ALIASED_TARGET)
if(TARGET "${original_name}")
message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. "
2022-10-15 01:15:03 +04:00
"It will be exported to the OpenVINODeveloperPackage with the original name.")
2020-12-22 18:44:59 +03:00
list(REMOVE_ITEM ${EXPORT_COMPONENT} ${target_name})
list(APPEND ${EXPORT_COMPONENT} ${original_name})
endif()
endif()
endforeach()
2020-12-22 18:44:59 +03:00
list(REMOVE_DUPLICATES ${EXPORT_COMPONENT})
set(${EXPORT_COMPONENT} "${${EXPORT_COMPONENT}}" CACHE INTERNAL
"A list of OpenVINO ${EXPORT_COMPONENT} exported targets" FORCE)
list(APPEND openvino_export_components ${EXPORT_COMPONENT})
list(REMOVE_DUPLICATES openvino_export_components)
set(openvino_export_components "${openvino_export_components}" CACHE INTERNAL
"A list of OpenVINO exported components" FORCE)
endfunction()
# add target with processed tests model zoo
if (ENABLE_TESTS)
include(cmake/test_model_zoo.cmake)
endif()
include(thirdparty/dependencies.cmake)
2021-11-27 11:28:25 +03:00
add_subdirectory(src)
if(ENABLE_SAMPLES OR ENABLE_TESTS)
add_subdirectory(samples)
endif()
2021-12-13 00:04:56 +03:00
# Enable interpreter backend for tests
2021-12-13 00:04:56 +03:00
if (ENABLE_TESTS OR ENABLE_TEMPLATE)
add_subdirectory(src/plugins/template/backend)
2021-12-13 00:04:56 +03:00
endif()
include(cmake/extra_modules.cmake)
2020-05-22 22:34:00 +03:00
add_subdirectory(docs)
add_subdirectory(tools)
add_subdirectory(scripts)
add_subdirectory(licensing)
2020-05-22 22:34:00 +03:00
2020-10-05 23:37:50 +03:00
#
# CPack
2020-10-05 23:37:50 +03:00
#
2020-04-28 22:20:54 +03:00
2022-07-19 10:07:26 +04:00
# provides a callback function to describe each component in repo
2022-07-27 14:04:22 +04:00
include(cmake/packaging/packaging.cmake)
2022-07-19 10:07:26 +04:00
2020-02-11 22:48:49 +03:00
ie_cpack(${IE_CPACK_COMPONENTS_ALL})