2023-01-16 11:02:17 +04:00
|
|
|
# Copyright (C) 2018-2023 Intel Corporation
|
2020-12-22 18:44:59 +03:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
include(options)
|
|
|
|
|
include(target_flags)
|
|
|
|
|
|
|
|
|
|
# FIXME: there are compiler failures with LTO and Cross-Compile toolchains. Disabling for now, but
|
|
|
|
|
# this must be addressed in a proper way
|
2022-12-04 22:55:52 +04:00
|
|
|
ie_dependent_option (ENABLE_LTO "Enable Link Time Optimization" OFF
|
2023-03-31 11:34:42 +04:00
|
|
|
"LINUX;EMSCRIPTEN OR NOT CMAKE_CROSSCOMPILING;CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
|
|
|
|
ie_option (OS_FOLDER "create OS dedicated folder in output" OFF)
|
|
|
|
|
|
2021-11-27 14:58:24 +03:00
|
|
|
if(OV_GENERATOR_MULTI_CONFIG)
|
2021-01-11 18:38:11 +03:00
|
|
|
ie_option(USE_BUILD_TYPE_SUBFOLDER "Create dedicated sub-folder per build type for output binaries" OFF)
|
2021-11-27 14:58:24 +03:00
|
|
|
else()
|
|
|
|
|
ie_option(USE_BUILD_TYPE_SUBFOLDER "Create dedicated sub-folder per build type for output binaries" ON)
|
2021-01-11 18:38:11 +03:00
|
|
|
endif()
|
|
|
|
|
|
2022-10-06 13:44:21 +04:00
|
|
|
if(CI_BUILD_NUMBER)
|
2023-02-09 11:30:07 +04:00
|
|
|
set(CMAKE_COMPILE_WARNING_AS_ERROR_DEFAULT ON)
|
2022-08-25 20:15:21 +04:00
|
|
|
else()
|
2023-02-09 11:30:07 +04:00
|
|
|
set(CMAKE_COMPILE_WARNING_AS_ERROR_DEFAULT OFF)
|
2022-08-25 20:15:21 +04:00
|
|
|
endif()
|
2022-10-06 13:44:21 +04:00
|
|
|
|
2023-02-09 11:30:07 +04:00
|
|
|
ie_option (CMAKE_COMPILE_WARNING_AS_ERROR "Enable warnings as errors" ${CMAKE_COMPILE_WARNING_AS_ERROR_DEFAULT})
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2023-03-24 13:55:42 +04:00
|
|
|
ie_dependent_option (ENABLE_QSPECTRE "Enable Qspectre mitigation" OFF "CMAKE_CXX_COMPILER_ID STREQUAL MSVC" OFF)
|
|
|
|
|
|
2021-07-05 09:48:05 +03:00
|
|
|
ie_dependent_option (ENABLE_INTEGRITYCHECK "build DLLs with /INTEGRITYCHECK flag" OFF "CMAKE_CXX_COMPILER_ID STREQUAL MSVC" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
|
|
|
|
ie_option (ENABLE_SANITIZER "enable checking memory errors via AddressSanitizer" OFF)
|
|
|
|
|
|
2021-07-05 18:53:11 +03:00
|
|
|
ie_option (ENABLE_UB_SANITIZER "enable UndefinedBahavior sanitizer" OFF)
|
|
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
ie_option (ENABLE_THREAD_SANITIZER "enable checking data races via ThreadSanitizer" OFF)
|
|
|
|
|
|
2023-01-27 06:27:59 +04:00
|
|
|
ie_dependent_option (ENABLE_COVERAGE "enable code coverage" OFF "CMAKE_COMPILER_IS_GNUCXX OR OV_COMPILER_IS_CLANG" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
|
|
|
|
# Defines CPU capabilities
|
|
|
|
|
|
2023-01-10 13:02:22 +04:00
|
|
|
ie_dependent_option (ENABLE_SSE42 "Enable SSE4.2 optimizations" ON "X86_64 OR (X86 AND NOT EMSCRIPTEN)" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2023-01-10 13:02:22 +04:00
|
|
|
ie_dependent_option (ENABLE_AVX2 "Enable AVX2 optimizations" ON "X86_64 OR (X86 AND NOT EMSCRIPTEN)" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2023-01-10 13:02:22 +04:00
|
|
|
ie_dependent_option (ENABLE_AVX512F "Enable AVX512 optimizations" ON "X86_64 OR (X86 AND NOT EMSCRIPTEN)" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2023-01-10 13:02:22 +04:00
|
|
|
# Type of build, we add this as an explicit option to default it to ON
|
2023-01-27 20:00:26 +04:00
|
|
|
get_property(BUILD_SHARED_LIBS_DEFAULT GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
|
2023-01-10 13:02:22 +04:00
|
|
|
ie_option (BUILD_SHARED_LIBS "Build as a shared library" ${BUILD_SHARED_LIBS_DEFAULT})
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2022-08-30 22:18:06 +04:00
|
|
|
# Android does not support SOVERSION
|
|
|
|
|
# see https://www.opengis.ch/2011/11/23/creating-non-versioned-shared-libraries-for-android/
|
2023-01-10 13:02:22 +04:00
|
|
|
ie_dependent_option (ENABLE_LIBRARY_VERSIONING "Enable libraries versioning" ON "NOT WIN32;NOT ANDROID;BUILD_SHARED_LIBS" OFF)
|
2022-08-30 22:18:06 +04:00
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
ie_dependent_option (ENABLE_FASTER_BUILD "Enable build features (PCH, UNITY) to speed up build time" OFF "CMAKE_VERSION VERSION_GREATER_EQUAL 3.16" OFF)
|
|
|
|
|
|
2023-01-27 20:00:26 +04:00
|
|
|
if(CMAKE_CROSSCOMPILING OR WIN32)
|
2022-08-25 20:15:21 +04:00
|
|
|
set(STYLE_CHECKS_DEFAULT OFF)
|
2023-01-10 13:02:22 +04:00
|
|
|
else()
|
|
|
|
|
set(STYLE_CHECKS_DEFAULT ON)
|
2022-08-25 20:15:21 +04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
ie_option (ENABLE_CPPLINT "Enable cpplint checks during the build" ${STYLE_CHECKS_DEFAULT})
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2021-07-31 17:21:35 +03:00
|
|
|
ie_dependent_option (ENABLE_CPPLINT_REPORT "Build cpplint report instead of failing the build" OFF "ENABLE_CPPLINT" OFF)
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2022-08-25 20:15:21 +04:00
|
|
|
ie_option (ENABLE_CLANG_FORMAT "Enable clang-format checks during the build" ${STYLE_CHECKS_DEFAULT})
|
2020-12-22 18:44:59 +03:00
|
|
|
|
2022-08-25 20:15:21 +04:00
|
|
|
ie_option (ENABLE_NCC_STYLE "Enable ncc style check" ${STYLE_CHECKS_DEFAULT})
|
2021-08-07 09:55:45 +03:00
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
ie_option (VERBOSE_BUILD "shows extra information about build" OFF)
|
|
|
|
|
|
|
|
|
|
ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF)
|
|
|
|
|
|
2023-05-17 00:47:55 +04:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1930)
|
|
|
|
|
# Visual Studio 2022: 1930-1939 = VS 17.0 (v143 toolset)
|
|
|
|
|
set(_msvc_version_2022 ON)
|
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "OV_COMPILER_IS_CLANG OR _msvc_version_2022" OFF)
|
2020-12-27 00:02:50 +03:00
|
|
|
|
2020-12-22 18:44:59 +03:00
|
|
|
#
|
|
|
|
|
# Check features
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
if(ENABLE_AVX512F)
|
|
|
|
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") AND (MSVC_VERSION VERSION_LESS 1920))
|
|
|
|
|
# 1920 version of MSVC 2019. In MSVC 2017 AVX512F not work
|
|
|
|
|
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6))
|
|
|
|
|
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
|
|
|
|
endif()
|
2022-12-04 22:55:52 +04:00
|
|
|
if (OV_COMPILER_IS_APPLECLANG AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10)
|
|
|
|
|
# TODO: clarify which AppleClang version supports avx512
|
2020-12-22 18:44:59 +03:00
|
|
|
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9))
|
|
|
|
|
set(ENABLE_AVX512F OFF CACHE BOOL "" FORCE)
|
|
|
|
|
endif()
|
|
|
|
|
endif()
|
|
|
|
|
|
2022-03-31 18:05:59 +03:00
|
|
|
set(CMAKE_VERBOSE_MAKEFILE ${VERBOSE_BUILD} CACHE BOOL "" FORCE)
|