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
14 # by means of developer package
15 include(check_features_ie)
17 # resolving dependencies for the project
21 # Fuzz tests also building without ENABLE_FUZZING
28 find_package(Threads REQUIRED)
30 unset(IEDeveloperPackageTargets CACHE)
31 function(ie_developer_export_targets)
32 set(IEDeveloperPackageTargets "${IEDeveloperPackageTargets};${ARGV}")
34 # to allow exporting of aliased targets with the original names
35 foreach(target_name ${IEDeveloperPackageTargets})
36 if(TARGET "${target_name}")
37 get_target_property(original_name ${target_name} ALIASED_TARGET)
38 if(TARGET "${original_name}")
39 message(STATUS "The name ${target_name} is an ALIAS for ${original_name}. "
40 "It will be exported to the InferenceEngineDeveloperPackage with the original name.")
41 list(REMOVE_ITEM IEDeveloperPackageTargets ${target_name})
42 list(APPEND IEDeveloperPackageTargets ${original_name})
47 list(REMOVE_DUPLICATES IEDeveloperPackageTargets)
48 set(IEDeveloperPackageTargets "${IEDeveloperPackageTargets}" CACHE INTERNAL
49 "Paths to extra Inference Engine plugins" FORCE)
52 function(ie_developer_export)
53 export(TARGETS ${IEDeveloperPackageTargets} NAMESPACE IE::
54 APPEND FILE "${CMAKE_BINARY_DIR}/targets_developer.cmake")
56 # Custom target to build only Inference Engine Developer Package targets
57 add_custom_target(ie_dev_targets ALL DEPENDS ${IEDeveloperPackageTargets} gflags)
60 add_subdirectory(thirdparty)
65 add_subdirectory(tests_deprecated)
66 add_subdirectory(tests)
69 add_subdirectory(tools)
71 function(ie_build_samples)
72 # samples should be build with the same flags as from OpenVINO package,
74 foreach(var CMAKE_CXX_FLAGS CMAKE_C_FLAGS CMAKE_CXX_STANDARD
75 CMAKE_EXE_LINKER_FLAGS CMAKE_POLICY_DEFAULT_CMP0063
76 CMAKE_CXX_VISIBILITY_PRESET CMAKE_C_VISIBILITY_PRESET
77 CMAKE_VISIBILITY_INLINES_HIDDEN CMAKE_POSITION_INDEPENDENT_CODE
78 THREADS_PREFER_PTHREAD_FLAG X86_64 X86 ARM AARCH64 LINUX
79 MINGW64 CMAKE_BUILD_TYPE CMAKE_MACOSX_RPATH)
83 add_subdirectory(samples)
86 # gflags and format_reader targets are kept inside of samples directory and
87 # they must be built even if samples build is disabled (required for tests and tools).
90 file(GLOB_RECURSE SAMPLES_SOURCES samples/*.cpp samples/*.hpp samples/*.h)
91 add_cpplint_target(sample_cpplint
92 FOR_SOURCES ${SAMPLES_SOURCES}
93 EXCLUDE_PATTERNS "thirdparty/*" "pugixml/*")
96 add_subdirectory(ie_bridges/python)
100 add_subdirectory(ie_bridges/c)
103 add_cpplint_report_target()
109 # install C++ samples
111 ie_cpack_add_component(cpp_samples REQUIRED DEPENDS core)
114 install(DIRECTORY samples/
115 DESTINATION ${IE_CPACK_IE_DIR}/samples/cpp
116 COMPONENT cpp_samples
117 USE_SOURCE_PERMISSIONS
118 PATTERN *.bat EXCLUDE
119 PATTERN speech_libs_and_demos EXCLUDE)
121 install(DIRECTORY samples/
122 DESTINATION ${IE_CPACK_IE_DIR}/samples/cpp
123 COMPONENT cpp_samples
124 USE_SOURCE_PERMISSIONS
126 PATTERN speech_libs_and_demos EXCLUDE)
131 ie_cpack_add_component(c_samples REQUIRED DEPENDS core)
134 install(PROGRAMS samples/build_samples.sh
135 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
138 install(PROGRAMS samples/build_samples_msvc.bat
139 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
143 install(DIRECTORY ie_bridges/c/samples/
144 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
146 PATTERN ie_bridges/c/samples/CMakeLists.txt EXCLUDE)
148 install(FILES samples/CMakeLists.txt
149 DESTINATION ${IE_CPACK_IE_DIR}/samples/c
152 # install Python samples
155 ie_cpack_add_component(python_samples REQUIRED DEPENDS core)
157 install(DIRECTORY ${ie_python_api_SOURCE_DIR}/sample/
158 DESTINATION ${IE_CPACK_IE_DIR}/samples/python
159 COMPONENT python_samples)
162 # install speech demo files
164 if(SPEECH_LIBS_AND_DEMOS)
165 ie_cpack_add_component(speech_demo_files REQUIRED)
167 install(DIRECTORY ${TEMP}/deployment_tools
168 ${TEMP}/data_processing
170 COMPONENT speech_demo_files)
177 ie_developer_export_targets(format_reader)
178 ie_developer_export_targets(${NGRAPH_LIBRARIES})
180 ie_developer_export()
183 "${IE_MAIN_SOURCE_DIR}/cmake/developer_package_config.cmake.in"
184 "${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig.cmake"
188 "${IE_MAIN_SOURCE_DIR}/cmake/share/InferenceEngineConfig-version.cmake.in"
189 "${CMAKE_BINARY_DIR}/InferenceEngineDeveloperPackageConfig-version.cmake"
204 function(register_extra_plugins)
205 set(InferenceEngineDeveloperPackage_DIR "${CMAKE_CURRENT_BINARY_DIR}/build-plugins")
206 set(iedevconfig_file "${InferenceEngineDeveloperPackage_DIR}/InferenceEngineDeveloperPackageConfig.cmake")
207 file(REMOVE "${iedevconfig_file}")
209 file(WRITE "${iedevconfig_file}" "\# !! AUTOGENERATED: DON'T EDIT !!\n\n")
210 file(APPEND "${iedevconfig_file}" "ie_deprecated_no_errors()\n")
212 foreach(target IN LISTS IEDeveloperPackageTargets)
214 file(APPEND "${iedevconfig_file}" "add_library(IE::${target} ALIAS ${target})\n")
218 # automatically import plugins from the 'plugins' folder
219 file(GLOB local_extra_plugins "plugins/*")
220 list(APPEND local_extra_plugins "${OpenVINO_MAIN_SOURCE_DIR}/docs/template_plugin")
222 foreach(plugin_path IN LISTS IE_EXTRA_PLUGINS local_extra_plugins)
223 get_filename_component(plugin_dir "${plugin_path}" NAME)
224 message(STATUS "Register ${plugin_dir} to be built in build-plugins/${plugin_dir}")
225 add_subdirectory("${plugin_path}" "build-plugins/${plugin_dir}")
229 register_extra_plugins()