1 # Copyright (C) 2018-2020 Intel Corporation
2 # SPDX-License-Identifier: Apache-2.0
5 cmake_policy(SET CMP0054 NEW)
7 # TODO: for make instal / package we need to use 3.13.3 version because
8 # it allows to install targets created outside of current projects
9 # See https://blog.kitware.com/cmake-3-13-0-available-for-download/
12 if(CMAKE_GENERATOR STREQUAL "Xcode")
13 # due to https://gitlab.kitware.com/cmake/cmake/issues/14254
14 cmake_minimum_required(VERSION 3.12.0 FATAL_ERROR)
16 # due to https://cmake.org/cmake/help/v3.12/policy/CMP0068.html
17 cmake_minimum_required(VERSION 3.9 FATAL_ERROR)
20 cmake_minimum_required(VERSION 3.7.2 FATAL_ERROR)
25 set(OpenVINO_MAIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
26 set(IE_MAIN_SOURCE_DIR ${OpenVINO_MAIN_SOURCE_DIR}/inference-engine)
27 list(APPEND CMAKE_MODULE_PATH "${OpenVINO_MAIN_SOURCE_DIR}/cmake")
32 # include developer package
33 include(developer_package)
35 # These options are shared with 3rdparty plugins
36 # by means of developer package
37 include(check_features)
40 # resolving dependencies for the project
41 message (STATUS "PROJECT ............................... " ${PROJECT_NAME})
42 message (STATUS "CMAKE_BINARY_DIR ...................... " ${CMAKE_BINARY_DIR})
43 message (STATUS "OpenVINO_MAIN_SOURCE_DIR .............. " ${OpenVINO_MAIN_SOURCE_DIR})
44 message (STATUS "IE_MAIN_SOURCE_DIR .................... " ${IE_MAIN_SOURCE_DIR})
45 message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
46 message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
47 message (STATUS "CMAKE_BUILD_TYPE ...................... " ${CMAKE_BUILD_TYPE})
49 # remove file with exported developer targets to force its regeneration
50 file(REMOVE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
51 file(REMOVE "${CMAKE_BINARY_DIR}/targets.cmake")
53 function(build_ngraph)
54 function(ngraph_set option value)
55 if(NOT DEFINED ${option})
56 set(${option} ${value} CACHE BOOL "" FORCE)
60 set(NGRAPH_BUILD_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} CACHE STRING "" FORCE)
61 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${OpenVINO_MAIN_SOURCE_DIR}/ngraph/cmake/Modules/")
64 ngraph_set(NGRAPH_ADDRESS_SANITIZER TRUE)
66 ngraph_set(NGRAPH_ADDRESS_SANITIZER FALSE)
68 ngraph_set(NGRAPH_PYTHON_BUILD_ENABLE FALSE)
70 if(ENABLE_TESTS AND NOT ANDROID)
71 ngraph_set(NGRAPH_UNIT_TEST_ENABLE TRUE)
73 ngraph_set(NGRAPH_UNIT_TEST_ENABLE FALSE)
77 ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE TRUE)
79 ngraph_set(NGRAPH_ONNX_IMPORT_ENABLE FALSE)
81 ngraph_set(NGRAPH_INTERPRETER_ENABLE TRUE)
83 if(CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
84 ie_add_compiler_flags(-Wno-error=uninitialized -Wno-error=literal-conversion)
86 ie_add_compiler_flags(-Wno-error=maybe-uninitialized -Wno-error=return-type -fPIC)
89 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=defaulted-function-deleted -Wno-error=unused-command-line-argument")
94 ie_add_compiler_flags(-Wno-error=return-type -Wno-undef)
96 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4308 /wd4146 /wd4703 /wd4244 /wd4819")
99 # Preserve the original flags for further use
100 set(CMAKE_ORIGINAL_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
101 set(CMAKE_ORIGINAL_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
102 set(CMAKE_ORIGINAL_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
103 set(CMAKE_ORIGINAL_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}")
104 set(CMAKE_ORIGINAL_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE}")
110 ie_cpack_add_component(ngraph)
112 set(SDL_cmake_included ON)
113 # set(NGRAPH_COMPONENT_PREFIX "deployment_tools/ngraph/")
114 add_subdirectory(ngraph)
115 set(NGRAPH_LIBRARIES ngraph PARENT_SCOPE)
118 file(REMOVE "${CMAKE_BINARY_DIR}/openvino_targets_developer.cmake")
120 unset(OpenVINODeveloperPackageTargets CACHE)
122 function(openvino_developer_export_targets)
123 set(OpenVINODeveloperPackageTargets "${OpenVINODeveloperPackageTargets};${ARGV}")
125 # to allow exporting of aliased targets with the original names
126 foreach(target_name ${OpenVINODeveloperPackageTargets})
127 if(TARGET "${target_name}")
128 get_target_property(original_name ${target_name} ALIASED_TARGET)
129 if(TARGET "${original_name}")
130 message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. "
131 "It will be exported to the InferenceEngineDeveloperPackage with the original name.")
132 list(REMOVE_ITEM OpenVINODeveloperPackageTargets ${target_name})
133 list(APPEND OpenVINODeveloperPackageTargets ${original_name})
138 list(REMOVE_DUPLICATES OpenVINODeveloperPackageTargets)
139 set(OpenVINODeveloperPackageTargets "${OpenVINODeveloperPackageTargets}" CACHE INTERNAL
140 "Paths to extra Inference Engine plugins" FORCE)
144 add_subdirectory(openvino)
148 add_subdirectory(inference-engine)
150 add_subdirectory(docs)
156 ie_cpack_add_component(setupvars REQUIRED)
159 install(PROGRAMS scripts/setupvars/setupvars.sh
163 install(PROGRAMS scripts/setupvars/setupvars.bat
168 # install install_dependencies
171 ie_cpack_add_component(install_dependencies REQUIRED)
172 install(DIRECTORY scripts/install_dependencies/
173 DESTINATION install_dependencies
174 COMPONENT install_dependencies)
177 # install files for demo
179 ie_cpack_add_component(demo_scripts REQUIRED DEPENDS core)
182 install(DIRECTORY scripts/demo/
183 DESTINATION deployment_tools/demo
184 COMPONENT demo_scripts
185 USE_SOURCE_PERMISSIONS
186 PATTERN *.bat EXCLUDE)
188 install(DIRECTORY scripts/demo/
189 DESTINATION deployment_tools/demo
190 COMPONENT demo_scripts
191 USE_SOURCE_PERMISSIONS
192 PATTERN *.sh EXCLUDE)
195 ie_cpack(${IE_CPACK_COMPONENTS_ALL})