2019-08-09 11:02:42 -05:00
|
|
|
# Copyright (C) 2018 Intel Corporation
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
|
|
|
2020-10-14 02:43:24 -05:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
2020-12-22 09:44:59 -06: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)
|
|
|
|
set(CI_BUILD_NUMBER "${CI_BUILD_NUMBER}" PARENT_SCOPE)
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
set_ci_build_number()
|
|
|
|
|
|
|
|
include(features)
|
2020-12-22 23:01:07 -06:00
|
|
|
include(message)
|
2020-12-22 09:44:59 -06:00
|
|
|
|
|
|
|
#
|
2020-11-02 15:55:49 -06:00
|
|
|
# Detect target
|
2020-12-22 09:44:59 -06:00
|
|
|
#
|
|
|
|
|
2020-11-02 15:55:49 -06:00
|
|
|
include(target_flags)
|
|
|
|
|
|
|
|
string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} ARCH_FOLDER)
|
|
|
|
if(X86_64)
|
|
|
|
set(ARCH_FOLDER intel64)
|
|
|
|
elseif(X86)
|
|
|
|
set(ARCH_FOLDER ia32)
|
|
|
|
elseif(MSVC AND ARM)
|
|
|
|
set(ARCH_FOLDER arm)
|
|
|
|
elseif(MSVC AND AARCH64)
|
|
|
|
set(ARCH_FOLDER arm64)
|
|
|
|
endif()
|
|
|
|
|
2020-04-13 13:17:23 -05:00
|
|
|
#
|
2020-12-22 09:44:59 -06:00
|
|
|
# Prepare temporary folder
|
2020-04-13 13:17:23 -05:00
|
|
|
#
|
2020-02-11 13:48:49 -06:00
|
|
|
|
2020-04-13 13:17:23 -05:00
|
|
|
function(set_temp_directory temp_variable source_tree_dir)
|
|
|
|
if (DEFINED ENV{DL_SDK_TEMP} AND NOT $ENV{DL_SDK_TEMP} STREQUAL "")
|
|
|
|
message(STATUS "DL_SDK_TEMP environment is set : $ENV{DL_SDK_TEMP}")
|
|
|
|
|
|
|
|
if (WIN32)
|
|
|
|
string(REPLACE "\\" "\\\\" temp $ENV{DL_SDK_TEMP})
|
|
|
|
else()
|
|
|
|
set(temp $ENV{DL_SDK_TEMP})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (ENABLE_ALTERNATIVE_TEMP)
|
|
|
|
set(ALTERNATIVE_PATH ${source_tree_dir}/temp)
|
|
|
|
endif()
|
|
|
|
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 09:44:59 -06: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()
|
|
|
|
if(NOT COMMAND find_host_program)
|
|
|
|
macro(find_host_program)
|
|
|
|
find_program(${ARGN})
|
|
|
|
endmacro()
|
|
|
|
endif()
|
|
|
|
|
2020-11-02 15:55:49 -06:00
|
|
|
#
|
|
|
|
# Common scripts
|
|
|
|
#
|
|
|
|
|
2020-12-22 09:44:59 -06:00
|
|
|
include(packaging)
|
2020-04-13 13:17:23 -05:00
|
|
|
include(coverage/coverage)
|
2020-10-05 15:37:50 -05:00
|
|
|
include(shellcheck/shellcheck)
|
2020-04-13 13:17:23 -05:00
|
|
|
|
2019-08-09 11:02:42 -05:00
|
|
|
# printing debug messages
|
|
|
|
include(debug)
|
|
|
|
|
|
|
|
if(OS_FOLDER)
|
2020-10-05 15:37:50 -05:00
|
|
|
message ("**** OS FOLDER IS: [${OS_FOLDER}]")
|
2020-12-22 09:44:59 -06:00
|
|
|
if(OS_FOLDER STREQUAL "ON")
|
2020-10-05 15:37:50 -05: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 11:02:42 -05:00
|
|
|
else()
|
|
|
|
set(BIN_FOLDER "bin/${ARCH_FOLDER}")
|
|
|
|
endif()
|
|
|
|
|
2021-01-11 05:49:33 -06:00
|
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
|
2020-12-22 09:44:59 -06:00
|
|
|
message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
|
2019-08-09 11:02:42 -05:00
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
2021-01-11 05:49:33 -06:00
|
|
|
else()
|
|
|
|
set(RELEASE_TYPES "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
|
|
|
|
list(FIND RELEASE_TYPES ${CMAKE_BUILD_TYPE} INDEX_FOUND)
|
|
|
|
if (INDEX_FOUND EQUAL -1)
|
|
|
|
message(FATAL_ERROR "CMAKE_BUILD_TYPE must be one of Debug, Release, RelWithDebInfo, or MinSizeRel")
|
|
|
|
endif()
|
2019-08-09 11:02:42 -05:00
|
|
|
endif()
|
2021-01-11 09:38:11 -06:00
|
|
|
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
|
|
if(USE_BUILD_TYPE_SUBFOLDER)
|
|
|
|
set(BIN_FOLDER "${BIN_FOLDER}/${CMAKE_BUILD_TYPE}")
|
|
|
|
endif()
|
2019-08-09 11:02:42 -05:00
|
|
|
|
2020-05-13 13:12:22 -05:00
|
|
|
# allow to override default OUTPUT_ROOT root
|
|
|
|
if(NOT DEFINED OUTPUT_ROOT)
|
2020-12-22 09:44:59 -06:00
|
|
|
if(NOT DEFINED OpenVINO_MAIN_SOURCE_DIR)
|
|
|
|
message(FATAL_ERROR "OpenVINO_MAIN_SOURCE_DIR is not defined")
|
|
|
|
endif()
|
2020-05-13 13:12:22 -05:00
|
|
|
set(OUTPUT_ROOT ${OpenVINO_MAIN_SOURCE_DIR})
|
|
|
|
endif()
|
2019-08-09 11:02:42 -05: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 "")
|
|
|
|
set(IE_DEBUG_POSTFIX_MAC "d")
|
|
|
|
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})
|
|
|
|
|
2020-12-22 09:44:59 -06:00
|
|
|
if (MSVC OR CMAKE_GENERATOR STREQUAL "Xcode")
|
2020-05-26 09:17:36 -05:00
|
|
|
# Support CMake multiconfiguration for Visual Studio or Xcode build
|
2019-08-09 11:02:42 -05:00
|
|
|
set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
|
|
|
|
else ()
|
2021-01-11 09:38:11 -06:00
|
|
|
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
|
2019-08-09 11:02:42 -05:00
|
|
|
set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
|
|
|
|
else()
|
|
|
|
set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
|
|
|
|
endif()
|
|
|
|
endif()
|
2020-12-22 09:44:59 -06:00
|
|
|
|
2019-08-09 11:02:42 -05:00
|
|
|
add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")
|
|
|
|
|
|
|
|
if(NOT UNIX)
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
else()
|
2021-01-11 09:38:11 -06:00
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/lib)
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/lib)
|
2019-08-09 11:02:42 -05:00
|
|
|
endif()
|
2021-01-11 09:38:11 -06:00
|
|
|
set(CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
set(CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
|
2019-08-09 11:02:42 -05:00
|
|
|
|
|
|
|
if(APPLE)
|
2020-12-22 09:44:59 -06:00
|
|
|
set(CMAKE_MACOSX_RPATH ON)
|
2020-05-26 09:17:36 -05: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 13:21:29 -05:00
|
|
|
endif()
|
2019-08-09 11:02:42 -05:00
|
|
|
|
|
|
|
# Use solution folders
|
|
|
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
|
|
|
|
2021-01-11 05:48:27 -06:00
|
|
|
# Enable CMAKE_<LANG>_COMPILER_ID AppleClang
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0025 NEW)
|
2020-05-13 13:12:22 -05:00
|
|
|
|
2020-10-14 02:43:24 -05:00
|
|
|
# LTO
|
|
|
|
|
2020-12-22 09:44:59 -06:00
|
|
|
if(ENABLE_LTO)
|
|
|
|
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
|
|
|
include(CheckIPOSupported)
|
2020-10-14 02:43:24 -05:00
|
|
|
|
2020-12-22 09:44:59 -06:00
|
|
|
check_ipo_supported(RESULT IPO_SUPPORTED
|
|
|
|
OUTPUT OUTPUT_MESSAGE
|
|
|
|
LANGUAGES C CXX)
|
2020-10-14 02:43:24 -05:00
|
|
|
|
2020-12-22 09:44:59 -06: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 02:43:24 -05:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# General flags
|
|
|
|
|
2020-12-22 09:44:59 -06:00
|
|
|
include(compile_flags/sdl)
|
|
|
|
include(compile_flags/os_flags)
|
|
|
|
include(compile_flags/sanitizer)
|
2020-12-26 15:02:50 -06:00
|
|
|
include(compile_flags/fuzzing)
|
2020-12-22 09:44:59 -06:00
|
|
|
include(download/dependency_solver)
|
|
|
|
include(cross_compile/cross_compiled_func)
|
2020-09-28 10:53:11 -05:00
|
|
|
include(faster_build)
|
2020-11-02 15:55:49 -06:00
|
|
|
include(whole_archive)
|
2020-12-22 09:44:59 -06:00
|
|
|
include(linux_name)
|
|
|
|
include(models)
|
2020-10-29 04:38:15 -05:00
|
|
|
include(api_validator/api_validator)
|
2019-08-09 11:02:42 -05:00
|
|
|
|
2020-10-30 13:38:34 -05:00
|
|
|
include(vs_version/vs_version)
|
2020-12-22 09:44:59 -06:00
|
|
|
include(plugins/plugins)
|
|
|
|
include(add_ie_target)
|
2020-11-26 06:38:55 -06:00
|
|
|
|
2020-12-26 15:02:50 -06:00
|
|
|
if(ENABLE_FUZZING)
|
|
|
|
enable_fuzzing()
|
|
|
|
endif()
|
|
|
|
|
2020-11-26 06:38:55 -06:00
|
|
|
# Code style utils
|
|
|
|
|
|
|
|
include(cpplint/cpplint)
|
|
|
|
include(clang_format/clang_format)
|
2020-12-22 09:44:59 -06:00
|
|
|
|
|
|
|
# Restore state
|
|
|
|
set(CMAKE_MODULE_PATH ${OLD_CMAKE_MODULE_PATH})
|