1 # Copyright (C) 2018-2020 Intel Corporation
2 # SPDX-License-Identifier: Apache-2.0
4 project(InferenceEngine)
6 set(CMAKE_MODULE_PATH "${IE_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
10 # include developer package
11 include(developer_package_ie)
13 # These options are shared with 3rdparty plugins by means of developer package
14 include(check_features_ie)
16 # resolving dependencies for the project
20 # Fuzz tests also building without ENABLE_FUZZING
27 find_package(Threads REQUIRED)
29 unset(IEDeveloperPackageTargets CACHE)
30 function(ie_developer_export_targets)
31 set(IEDeveloperPackageTargets "${IEDeveloperPackageTargets};${ARGV}")
33 # to allow exporting of aliased targets with the original names
34 foreach(target_name ${IEDeveloperPackageTargets})
35 if(TARGET "${target_name}")
36 get_target_property(original_name ${target_name} ALIASED_TARGET)
37 if(TARGET "${original_name}")
38 message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. "
39 "It will be exported to the InferenceEngineDeveloperPackage with the original name.")
40 list(REMOVE_ITEM IEDeveloperPackageTargets ${target_name})
41 list(APPEND IEDeveloperPackageTargets ${original_name})
46 list(REMOVE_DUPLICATES IEDeveloperPackageTargets)
47 set(IEDeveloperPackageTargets "${IEDeveloperPackageTargets}" CACHE INTERNAL
48 "Paths to extra Inference Engine plugins" FORCE)
51 function(ie_developer_export)
52 export(TARGETS ${OpenVINODeveloperPackageTargets} NAMESPACE IE::
53 APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
55 export(TARGETS ${IEDeveloperPackageTargets} NAMESPACE IE::
56 APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
58 # Custom target to build only Inference Engine Developer Package targets
59 add_custom_target(ie_dev_targets ALL DEPENDS ${OpenVINODeveloperPackageTargets} ${IEDeveloperPackageTargets} gflags
60 inference_engine_ir_reader inference_engine_ir_v7_reader)
63 add_subdirectory(thirdparty)
68 add_subdirectory(tests_deprecated)
69 add_subdirectory(tests)
72 add_subdirectory(tools)
74 function(ie_build_samples)
75 # samples should be build with the same flags as from OpenVINO package,
77 foreach(var CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_STANDARD
78 CMAKE_EXE_LINKER_FLAGS CMAKE_POLICY_DEFAULT_CMP0063
79 CMAKE_CXX_VISIBILITY_PRESET CMAKE_C_VISIBILITY_PRESET
80 CMAKE_VISIBILITY_INLINES_HIDDEN CMAKE_POSITION_INDEPENDENT_CODE
81 THREADS_PREFER_PTHREAD_FLAG X86_64 X86 ARM AARCH64 LINUX
82 MINGW64 CMAKE_BUILD_TYPE CMAKE_MACOSX_RPATH)
86 add_subdirectory(samples)
89 # gflags and format_reader targets are kept inside of samples directory and
90 # they must be built even if samples build is disabled (required for tests and tools).
93 file(GLOB_RECURSE SAMPLES_SOURCES samples/*.cpp samples/*.hpp samples/*.h)
94 add_cpplint_target(sample_cpplint
95 FOR_SOURCES ${SAMPLES_SOURCES}
96 EXCLUDE_PATTERNS "thirdparty/*" "pugixml/*")
99 add_subdirectory(ie_bridges/python)
102 add_subdirectory(ie_bridges/c)
105 add_subdirectory(ie_bridges/java)
108 add_cpplint_report_target()
114 # install C++ samples
116 ie_cpack_add_component(cpp_samples REQUIRED DEPENDS core)
119 install(DIRECTORY samples/
120 DESTINATION ${IE_CPACK_IE_DIR}/samples/cpp
121 COMPONENT cpp_samples
122 USE_SOURCE_PERMISSIONS
123 PATTERN *.bat EXCLUDE
124 PATTERN speech_libs_and_demos EXCLUDE)
126 install(DIRECTORY samples/
127 DESTINATION ${IE_CPACK_IE_DIR}/samples/cpp
128 COMPONENT cpp_samples
129 USE_SOURCE_PERMISSIONS
131 PATTERN speech_libs_and_demos EXCLUDE)
136 ie_cpack_add_component(c_samples REQUIRED DEPENDS core)
139 install(PROGRAMS samples/build_samples.sh
140 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
143 install(PROGRAMS samples/build_samples_msvc.bat
144 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
148 install(DIRECTORY ie_bridges/c/samples/
149 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
151 PATTERN ie_bridges/c/samples/CMakeLists.txt EXCLUDE)
153 install(FILES samples/CMakeLists.txt
154 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
157 # install Python samples
160 ie_cpack_add_component(python_samples REQUIRED DEPENDS core)
162 install(DIRECTORY ${ie_python_api_SOURCE_DIR}/sample/
163 DESTINATION ${IE_CPACK_IE_DIR}/samples/python
164 COMPONENT python_samples)
167 # install speech demo files
169 if(SPEECH_LIBS_AND_DEMOS)
170 ie_cpack_add_component(speech_demo_files REQUIRED)
172 install(DIRECTORY ${TEMP}/deployment_tools
173 ${TEMP}/data_processing
175 COMPONENT speech_demo_files)
182 ie_developer_export_targets(format_reader)
183 ie_developer_export_targets(${NGRAPH_LIBRARIES})
185 # for Template plugin
186 if(NGRAPH_INTERPRETER_ENABLE)
187 ie_developer_export_targets(ngraph_backend interpreter_backend)
190 ie_developer_export()
193 "${IE_MAIN_SOURCE_DIR}/cmake/developer_package_config.cmake.in"
194 "${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
198 "${IE_MAIN_SOURCE_DIR}/cmake/share/InferenceEngineConfig-version.cmake.in"
199 "${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
214 function(register_extra_modules)
215 set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/build-modules")
217 function(generate_fake_dev_package)
218 set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
219 file(REMOVE "${iedevconfig_file}")
221 file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
222 file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")
224 foreach(target IN LISTS OpenVINODeveloperPackageTargets IEDeveloperPackageTargets)
226 file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
231 generate_fake_dev_package()
233 # automatically import plugins from the 'plugins' folder
234 file(GLOB local_extra_modules "plugins/*")
235 if(NGRAPH_INTERPRETER_ENABLE)
236 list(APPEND local_extra_modules "${OpenVINO_MAIN_SOURCE_DIR}/docs/template_plugin")
239 # detect where IE_EXTRA_MODULES contains folders with CMakeLists.txt
240 # other folders are supposed to have sub-folders with CMakeLists.txt
241 foreach(module_path IN LISTS IE_EXTRA_MODULES)
242 if(EXISTS "${module_path}/CMakeLists.txt")
243 list(APPEND extra_modules "${module_path}")
245 file(GLOB extra_modules ${extra_modules} "${module_path}/*")
249 # add each extra module
250 foreach(module_path IN LISTS extra_modules local_extra_modules)
252 get_filename_component(module_name "${module_path}" NAME)
254 if(NOT EXISTS "${module_path}/CMakeLists.txt") # if module is built not using cmake
255 set(build_module OFF)
257 if(NOT DEFINED BUILD_${module_name})
258 set(BUILD_${module_name} ${build_module} CACHE BOOL "Build ${module_name} extra module" FORCE)
260 if(BUILD_${module_name})
261 message(STATUS "Register ${module_name} to be built in build-modules/${module_name}")
262 add_subdirectory("${module_path}" "build-modules/${module_name}")
268 register_extra_modules()