2022-01-19 01:07:49 +03:00
|
|
|
# Copyright (C) 2018-2022 Intel Corporation
|
2019-08-09 19:02:42 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
|
2020-10-14 10:43:24 +03:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
if(NOT DEFINED IEDevScripts_DIR)
|
|
|
|
|
message(FATAL_ERROR "IEDevScripts_DIR is not defined")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(OLD_CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH})
|
|
|
|
|
set(CMAKE_MODULE_PATH "${IEDevScripts_DIR}")
|
|
|
|
|
|
|
|
|
|
function(set_ci_build_number)
|
|
|
|
|
set(repo_root "${CMAKE_SOURCE_DIR}")
|
|
|
|
|
include(version)
|
2022-08-08 13:59:24 +04:00
|
|
|
foreach(var CI_BUILD_NUMBER OpenVINO_VERSION OpenVINO_SOVERSION OpenVINO_VERSION_SUFFIX OpenVINO_VERSION_BUILD
|
2022-03-28 19:32:21 +03:00
|
|
|
OpenVINO_VERSION_MAJOR OpenVINO_VERSION_MINOR OpenVINO_VERSION_PATCH)
|
2021-05-20 10:21:44 +03:00
|
|
|
if(NOT DEFINED ${var})
|
|
|
|
|
message(FATAL_ERROR "${var} version component is not defined")
|
|
|
|
|
endif()
|
|
|
|
|
set(${var} "${${var}}" PARENT_SCOPE)
|
|
|
|
|
endforeach()
|
2020-12-22 18:44:59 +03:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
include(features)
|
2020-12-23 08:01:07 +03:00
|
|
|
include(message)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2022-08-30 22:18:06 +04:00
|
|
|
set_ci_build_number()
|
|
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
#
|
2020-11-03 00:55:49 +03:00
|
|
|
# Detect target
|
2020-12-22 18:44:59 +03:00
|
|
|
#
|
|
|
|
|
|
2020-11-03 00:55:49 +03:00
|
|
|
include(target_flags)
|
|
|
|
|
|
2022-09-01 14:33:47 +04:00
|
|
|
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCH_FOLDER)
|
2020-11-03 00:55:49 +03:00
|
|
|
if(X86_64)
|
|
|
|
|
set(ARCH_FOLDER intel64)
|
|
|
|
|
elseif(X86)
|
|
|
|
|
set(ARCH_FOLDER ia32)
|
|
|
|
|
elseif(MSVC AND ARM)
|
|
|
|
|
set(ARCH_FOLDER arm)
|
2022-10-05 00:34:36 +04:00
|
|
|
elseif((MSVC OR APPLE) AND AARCH64)
|
2020-11-03 00:55:49 +03:00
|
|
|
set(ARCH_FOLDER arm64)
|
2022-09-19 10:14:07 +04:00
|
|
|
elseif(UNIVERSAL2)
|
|
|
|
|
set(ARCH_FOLDER universal2)
|
2020-11-03 00:55:49 +03:00
|
|
|
endif()
|
|
|
|
|
|
2020-04-13 21:17:23 +03:00
|
|
|
#
|
2020-12-22 18:44:59 +03:00
|
|
|
# Prepare temporary folder
|
2020-04-13 21:17:23 +03:00
|
|
|
#
|
2020-02-11 22:48:49 +03:00
|
|
|
|
2020-04-13 21:17:23 +03:00
|
|
|
function(set_temp_directory temp_variable source_tree_dir)
|
2021-11-24 08:37:26 +03:00
|
|
|
if(DEFINED OV_TEMP)
|
|
|
|
|
message(STATUS "OV_TEMP cmake variable is set : ${OV_TEMP}")
|
|
|
|
|
file(TO_CMAKE_PATH ${OV_TEMP} temp)
|
|
|
|
|
elseif (DEFINED ENV{DL_SDK_TEMP} AND NOT $ENV{DL_SDK_TEMP} STREQUAL "")
|
2020-04-13 21:17:23 +03:00
|
|
|
message(STATUS "DL_SDK_TEMP environment is set : $ENV{DL_SDK_TEMP}")
|
2021-01-25 19:06:12 +03:00
|
|
|
file(TO_CMAKE_PATH $ENV{DL_SDK_TEMP} temp)
|
2020-04-13 21:17:23 +03:00
|
|
|
else ()
|
|
|
|
|
set(temp ${source_tree_dir}/temp)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set("${temp_variable}" "${temp}" CACHE PATH "Path to temp directory")
|
|
|
|
|
if(ALTERNATIVE_PATH)
|
|
|
|
|
set(ALTERNATIVE_PATH "${ALTERNATIVE_PATH}" PARENT_SCOPE)
|
|
|
|
|
endif()
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
#
|
|
|
|
|
# For cross-compilation
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
# Search packages for the host system instead of packages for the target system
|
|
|
|
|
# in case of cross compilation these macros should be defined by the toolchain file
|
|
|
|
|
if(NOT COMMAND find_host_package)
|
|
|
|
|
macro(find_host_package)
|
|
|
|
|
find_package(${ARGN})
|
|
|
|
|
endmacro()
|
|
|
|
|
endif()
|
2022-09-26 07:48:41 +04:00
|
|
|
if(NOT COMMAND find_host_library)
|
|
|
|
|
macro(find_host_library)
|
|
|
|
|
find_library(${ARGN})
|
|
|
|
|
endmacro()
|
|
|
|
|
endif()
|
2020-12-22 18:44:59 +03:00
|
|
|
if(NOT COMMAND find_host_program)
|
|
|
|
|
macro(find_host_program)
|
|
|
|
|
find_program(${ARGN})
|
|
|
|
|
endmacro()
|
|
|
|
|
endif()
|
|
|
|
|
|
2020-11-03 00:55:49 +03:00
|
|
|
#
|
|
|
|
|
# Common scripts
|
|
|
|
|
#
|
|
|
|
|
|
2020-04-13 21:17:23 +03:00
|
|
|
include(coverage/coverage)
|
2020-10-05 23:37:50 +03:00
|
|
|
include(shellcheck/shellcheck)
|
2020-04-13 21:17:23 +03:00
|
|
|
|
2019-08-09 19:02:42 +03:00
|
|
|
# printing debug messages
|
|
|
|
|
include(debug)
|
|
|
|
|
|
|
|
|
|
if(OS_FOLDER)
|
2020-10-05 23:37:50 +03:00
|
|
|
message ("**** OS FOLDER IS: [${OS_FOLDER}]")
|
2020-12-22 18:44:59 +03:00
|
|
|
if(OS_FOLDER STREQUAL "ON")
|
2020-10-05 23:37:50 +03:00
|
|
|
message ("**** USING OS FOLDER: [${CMAKE_SYSTEM_NAME}]")
|
|
|
|
|
set(BIN_FOLDER "bin/${CMAKE_SYSTEM_NAME}/${ARCH_FOLDER}")
|
|
|
|
|
else()
|
|
|
|
|
set(BIN_FOLDER "bin/${OS_FOLDER}/${ARCH_FOLDER}")
|
|
|
|
|
endif()
|
2019-08-09 19:02:42 +03:00
|
|
|
else()
|
|
|
|
|
set(BIN_FOLDER "bin/${ARCH_FOLDER}")
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-11-27 14:58:24 +03:00
|
|
|
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "CMake build type")
|
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Release;Debug;RelWithDebInfo;MinSizeRel")
|
|
|
|
|
if(CMAKE_GENERATOR MATCHES "^Ninja Multi-Config$")
|
|
|
|
|
set(CMAKE_DEFAULT_BUILD_TYPE "Release" CACHE STRING "CMake default build type")
|
2019-08-09 19:02:42 +03:00
|
|
|
endif()
|
2021-01-11 18:38:11 +03:00
|
|
|
|
|
|
|
|
if(USE_BUILD_TYPE_SUBFOLDER)
|
|
|
|
|
set(BIN_FOLDER "${BIN_FOLDER}/${CMAKE_BUILD_TYPE}")
|
|
|
|
|
endif()
|
2019-08-09 19:02:42 +03:00
|
|
|
|
2020-05-13 21:12:22 +03:00
|
|
|
# allow to override default OUTPUT_ROOT root
|
|
|
|
|
if(NOT DEFINED OUTPUT_ROOT)
|
2021-07-02 11:36:31 +03:00
|
|
|
if(NOT DEFINED OpenVINO_SOURCE_DIR)
|
|
|
|
|
message(FATAL_ERROR "OpenVINO_SOURCE_DIR is not defined")
|
2020-12-22 18:44:59 +03:00
|
|
|
endif()
|
2021-07-02 11:36:31 +03:00
|
|
|
set(OUTPUT_ROOT ${OpenVINO_SOURCE_DIR})
|
2020-05-13 21:12:22 +03:00
|
|
|
endif()
|
2019-08-09 19:02:42 +03:00
|
|
|
|
|
|
|
|
# Enable postfixes for Debug/Release builds
|
|
|
|
|
set(IE_DEBUG_POSTFIX_WIN "d")
|
|
|
|
|
set(IE_RELEASE_POSTFIX_WIN "")
|
|
|
|
|
set(IE_DEBUG_POSTFIX_LIN "")
|
|
|
|
|
set(IE_RELEASE_POSTFIX_LIN "")
|
2022-02-01 12:41:26 +03:00
|
|
|
set(IE_DEBUG_POSTFIX_MAC "d")
|
2019-08-09 19:02:42 +03:00
|
|
|
set(IE_RELEASE_POSTFIX_MAC "")
|
|
|
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
|
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_WIN})
|
|
|
|
|
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_WIN})
|
|
|
|
|
elseif(APPLE)
|
|
|
|
|
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_MAC})
|
|
|
|
|
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_MAC})
|
|
|
|
|
else()
|
|
|
|
|
set(IE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX_LIN})
|
|
|
|
|
set(IE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX_LIN})
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
set(CMAKE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX})
|
|
|
|
|
set(CMAKE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX})
|
|
|
|
|
|
2021-11-27 14:58:24 +03:00
|
|
|
# Support CMake multi-configuration for Visual Studio / Ninja or Xcode build
|
|
|
|
|
if (OV_GENERATOR_MULTI_CONFIG)
|
2019-08-09 19:02:42 +03:00
|
|
|
set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
|
|
|
|
|
else ()
|
2021-01-11 18:38:11 +03:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2019-08-09 19:02:42 +03:00
|
|
|
set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
|
|
|
|
|
else()
|
|
|
|
|
set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")
|
|
|
|
|
|
2022-02-21 22:39:26 +03:00
|
|
|
macro(ov_set_if_not_defined var value)
|
|
|
|
|
if(NOT DEFINED ${var})
|
|
|
|
|
set(${var} ${value})
|
|
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2022-08-08 13:59:24 +04:00
|
|
|
ov_set_if_not_defined(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
|
ov_set_if_not_defined(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
2022-02-21 22:39:26 +03:00
|
|
|
ov_set_if_not_defined(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
|
ov_set_if_not_defined(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
|
ov_set_if_not_defined(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
2019-08-09 19:02:42 +03:00
|
|
|
|
2022-10-12 12:16:13 +04:00
|
|
|
if(CPACK_GENERATOR MATCHES "^(DEB|RPM)$")
|
2022-08-12 00:07:21 +04:00
|
|
|
# to make sure that lib/<multiarch-tuple> is created on Debian
|
|
|
|
|
set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Cmake install prefix" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
|
2019-08-09 19:02:42 +03:00
|
|
|
if(APPLE)
|
2020-12-22 18:44:59 +03:00
|
|
|
set(CMAKE_MACOSX_RPATH ON)
|
2020-05-26 17:17:36 +03:00
|
|
|
# WA for Xcode generator + object libraries issue:
|
|
|
|
|
# https://gitlab.kitware.com/cmake/cmake/issues/20260
|
|
|
|
|
# http://cmake.3232098.n2.nabble.com/XCODE-DEPEND-HELPER-make-Deletes-Targets-Before-and-While-They-re-Built-td7598277.html
|
|
|
|
|
set(CMAKE_XCODE_GENERATE_TOP_LEVEL_PROJECT_ONLY ON)
|
2020-04-27 21:21:29 +03:00
|
|
|
endif()
|
2019-08-09 19:02:42 +03:00
|
|
|
|
|
|
|
|
# Use solution folders
|
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
|
2022-04-05 04:47:22 +03:00
|
|
|
# cmake_dependent_option() supports full Condition Syntax
|
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0127 NEW)
|
2021-01-11 14:48:27 +03:00
|
|
|
# Enable CMAKE_<LANG>_COMPILER_ID AppleClang
|
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0025 NEW)
|
2020-05-13 21:12:22 +03:00
|
|
|
|
2021-07-30 13:54:09 +03:00
|
|
|
set(CMAKE_WARN_DEPRECATED OFF CACHE BOOL "Don't warn about obsolete cmake versions in 3rdparty")
|
|
|
|
|
set(CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION ON CACHE BOOL "Warn about absolute paths in destination")
|
2022-07-19 10:07:26 +04:00
|
|
|
set(CMAKE_SKIP_INSTALL_RPATH ON)
|
2021-06-28 22:50:41 +03:00
|
|
|
|
2022-08-08 13:59:24 +04:00
|
|
|
include(packaging/packaging)
|
|
|
|
|
|
2020-10-14 10:43:24 +03:00
|
|
|
# LTO
|
|
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
if(ENABLE_LTO)
|
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
|
|
|
|
include(CheckIPOSupported)
|
2020-10-14 10:43:24 +03:00
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
check_ipo_supported(RESULT IPO_SUPPORTED
|
|
|
|
|
OUTPUT OUTPUT_MESSAGE
|
|
|
|
|
LANGUAGES C CXX)
|
2020-10-14 10:43:24 +03:00
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
if(NOT IPO_SUPPORTED)
|
|
|
|
|
set(ENABLE_LTO "OFF" CACHE STRING "Enable Link Time Optmization" FORCE)
|
|
|
|
|
message(WARNING "IPO / LTO is not supported: ${OUTPUT_MESSAGE}")
|
|
|
|
|
endif()
|
2020-10-14 10:43:24 +03:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
# General flags
|
|
|
|
|
|
2021-11-10 18:25:51 +03:00
|
|
|
macro(ov_install_static_lib target comp)
|
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
2022-03-02 03:39:30 +03:00
|
|
|
get_target_property(target_type ${target} TYPE)
|
|
|
|
|
if(${target_type} STREQUAL "STATIC_LIBRARY")
|
|
|
|
|
set_target_properties(${target} PROPERTIES EXCLUDE_FROM_ALL FALSE)
|
|
|
|
|
endif()
|
2021-11-10 18:25:51 +03:00
|
|
|
install(TARGETS ${target} EXPORT OpenVINOTargets
|
2022-07-19 10:07:26 +04:00
|
|
|
ARCHIVE DESTINATION ${OV_CPACK_ARCHIVEDIR} COMPONENT ${comp} ${ARGN})
|
2021-11-10 18:25:51 +03:00
|
|
|
endif()
|
|
|
|
|
endmacro()
|
|
|
|
|
|
2021-03-15 13:07:38 +03:00
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
|
find_package(Threads REQUIRED)
|
|
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
include(compile_flags/sdl)
|
|
|
|
|
include(compile_flags/os_flags)
|
|
|
|
|
include(compile_flags/sanitizer)
|
2020-12-27 00:02:50 +03:00
|
|
|
include(compile_flags/fuzzing)
|
2020-12-22 18:44:59 +03:00
|
|
|
include(download/dependency_solver)
|
|
|
|
|
include(cross_compile/cross_compiled_func)
|
2020-09-28 18:53:11 +03:00
|
|
|
include(faster_build)
|
2020-11-03 00:55:49 +03:00
|
|
|
include(whole_archive)
|
2020-12-22 18:44:59 +03:00
|
|
|
include(linux_name)
|
|
|
|
|
include(models)
|
2020-10-29 12:38:15 +03:00
|
|
|
include(api_validator/api_validator)
|
2019-08-09 19:02:42 +03:00
|
|
|
|
2020-10-30 21:38:34 +03:00
|
|
|
include(vs_version/vs_version)
|
2020-12-22 18:44:59 +03:00
|
|
|
include(plugins/plugins)
|
2021-11-28 21:36:24 +03:00
|
|
|
include(frontends/frontends)
|
2020-12-22 18:44:59 +03:00
|
|
|
include(add_ie_target)
|
2021-06-03 12:45:12 +03:00
|
|
|
include(CMakePackageConfigHelpers)
|
2020-11-26 15:38:55 +03:00
|
|
|
|
2020-12-27 00:02:50 +03:00
|
|
|
if(ENABLE_FUZZING)
|
|
|
|
|
enable_fuzzing()
|
|
|
|
|
endif()
|
|
|
|
|
|
2021-02-17 15:41:54 +03:00
|
|
|
# macro to mark target as conditionally compiled
|
|
|
|
|
|
|
|
|
|
function(ie_mark_target_as_cc TARGET_NAME)
|
2021-11-16 06:48:02 +03:00
|
|
|
set(cc_library openvino::conditional_compilation)
|
|
|
|
|
if(TARGET IE::conditional_compilation)
|
|
|
|
|
set(cc_library IE::conditional_compilation)
|
|
|
|
|
endif()
|
|
|
|
|
target_link_libraries(${TARGET_NAME} PRIVATE ${cc_library})
|
2021-03-16 14:04:48 +03:00
|
|
|
|
2021-02-17 15:41:54 +03:00
|
|
|
if(NOT (SELECTIVE_BUILD STREQUAL "ON"))
|
|
|
|
|
return()
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
if(NOT TARGET ${TARGET_NAME})
|
|
|
|
|
message(FATAL_ERROR "${TARGET_NAME} does not represent target")
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
get_target_property(sources ${TARGET_NAME} SOURCES)
|
|
|
|
|
set_source_files_properties(${sources} PROPERTIES OBJECT_DEPENDS ${GENERATED_HEADER})
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2021-12-23 14:59:24 +03:00
|
|
|
function(ov_mark_target_as_cc)
|
|
|
|
|
ie_mark_target_as_cc(${ARGN})
|
|
|
|
|
endfunction()
|
|
|
|
|
|
2022-08-16 14:43:30 +04:00
|
|
|
include(python_requirements)
|
2021-07-05 09:48:05 +03:00
|
|
|
|
2020-11-26 15:38:55 +03:00
|
|
|
# Code style utils
|
|
|
|
|
|
|
|
|
|
include(cpplint/cpplint)
|
|
|
|
|
include(clang_format/clang_format)
|
2021-08-07 09:55:45 +03:00
|
|
|
include(ncc_naming_style/ncc_naming_style)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
|
|
|
|
# Restore state
|
|
|
|
|
set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH})
|