1 # Copyright (C) 2018 Intel Corporation
2 # SPDX-License-Identifier: Apache-2.0
5 cmake_minimum_required (VERSION 3.3)
7 project(InferenceEngine)
11 ## WA for problem with gtest submodule. It cannot detect uint32 type.
12 ## remove Gtest submodule and this two lines together
13 include (CheckTypeSize)
14 check_type_size (uint32_t uint32_t LANGUAGE CXX)
16 if (UNIX AND NOT APPLE)
20 option (OS_FOLDER "create OS dedicated folder in output" OFF)
22 if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
23 set (ARCH_FOLDER armv7l)
24 elseif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
25 set (ARCH_FOLDER intel64)
27 set (ARCH_FOLDER ia32)
31 message ("**** OS FOLDER IS: [${OS_FOLDER}]")
32 if ("${OS_FOLDER}" STREQUAL "ON")
33 message ("**** USING OS FOLDER: [${CMAKE_SYSTEM_NAME}]")
34 set (BIN_FOLDER bin/${CMAKE_SYSTEM_NAME}/${ARCH_FOLDER})
36 set (BIN_FOLDER bin/${OS_FOLDER}/${ARCH_FOLDER})
39 set (BIN_FOLDER bin/${ARCH_FOLDER})
42 set (IE_MAIN_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
43 set (CMAKE_MODULE_PATH "${IE_MAIN_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
45 #printing debug messages
48 if("${CMAKE_BUILD_TYPE}" STREQUAL "")
49 debug_message(STATUS "CMAKE_BUILD_TYPE not defined, 'Release' will be used")
50 set(CMAKE_BUILD_TYPE "Release")
52 message(STATUS "BUILD_CONFIGURATION: ${CMAKE_BUILD_TYPE}")
55 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -O0")
59 SET(LIB_DL ${CMAKE_DL_LIBS})
62 set (OUTPUT_ROOT ${IE_MAIN_SOURCE_DIR})
66 #resolving dependencies for the project
67 include (dependencies)
69 set(CMAKE_DEBUG_POSTFIX ${IE_DEBUG_POSTFIX})
70 set(CMAKE_RELEASE_POSTFIX ${IE_RELEASE_POSTFIX})
73 # Support CMake multiconfiguration for Visual Studio build
74 set(IE_BUILD_POSTFIX $<$<CONFIG:Debug>:${IE_DEBUG_POSTFIX}>$<$<CONFIG:Release>:${IE_RELEASE_POSTFIX}>)
75 set(IE_BUILD_CONFIGURATION $<CONFIG>)
77 if (${CMAKE_BUILD_TYPE} STREQUAL "Debug" )
78 set(IE_BUILD_POSTFIX ${IE_DEBUG_POSTFIX})
80 set(IE_BUILD_POSTFIX ${IE_RELEASE_POSTFIX})
82 set(IE_BUILD_CONFIGURATION ${CMAKE_BUILD_TYPE})
85 add_definitions(-DIE_BUILD_POSTFIX=\"${IE_BUILD_POSTFIX}\")
89 #set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
90 #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
92 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
93 set (CMAKE_LIBRARY_PATH ${OUTPUT_ROOT}/${BIN_FOLDER})
94 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
95 set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
96 set (CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
97 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
98 set (LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER})
99 set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}) # compatibility issue: linux uses LIBRARY_OUTPUT_PATH, windows uses LIBRARY_OUTPUT_DIRECTORY
101 set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
102 set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
103 set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION})
104 set (CMAKE_PDB_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION})
105 set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION})
106 set (LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_ROOT}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
107 set (LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_DIRECTORY}/lib)
111 set(CMAKE_MACOSX_RPATH 1)
114 #rpath fully disabled
115 if (NOT ENABLE_PLUGIN_RPATH)
116 SET (CMAKE_SKIP_RPATH TRUE)
119 #Use solution folders.
120 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
121 #message("=====================> ${CMAKE_BUILD_TYPE} <=====================")
123 message (STATUS "PROJECT ............................... " ${PROJECT_NAME})
124 message (STATUS "CMAKE_BINARY_DIR ...................... " ${CMAKE_BINARY_DIR})
125 message (STATUS "IE_MAIN_SOURCE_DIR .................... " ${IE_MAIN_SOURCE_DIR})
126 message (STATUS "CMAKE_GENERATOR ....................... " ${CMAKE_GENERATOR})
127 message (STATUS "CMAKE_C_COMPILER_ID ................... " ${CMAKE_C_COMPILER_ID})
131 set (CMAKE_POSITION_INDEPENDENT_CODE ON)
135 include(CheckCXXCompilerFlag)
137 CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" COMPILER_SUPPORTS_VISIBILITY)
138 if (COMPILER_SUPPORTS_VISIBILITY)
139 #add_definitions(-fvisibility=hidden) todo: should be hidden? if so define default visibiliti explicite for each funtion
140 add_definitions(-fvisibility=default)
141 endif(COMPILER_SUPPORTS_VISIBILITY)
144 add_subdirectory(src)
145 add_subdirectory(tests)
146 add_subdirectory(thirdparty)
147 if (ENABLE_SAMPLES_CORE)
148 set(InferenceEngine_DIR "${CMAKE_BINARY_DIR}")
151 set (LIB_FOLDER ${IE_MAIN_SOURCE_DIR}/${BIN_FOLDER}/${IE_BUILD_CONFIGURATION}/lib)
152 add_subdirectory(samples)
156 add_subdirectory(ie_bridges/python)