Improvements in cmake scripts (#4766)

1. Find Threads only once in IEDevScripts package
2. Small refactoring in IE Dev Package
This commit is contained in:
Ilya Lavrenov authored and GitHub committed 2021-03-15 13:07:38 +03:00
1 parent 753f4d5918
commit 24fb09edb3
12 files changed
+33 -76

No files matched your search

@@ -202,6 +202,9 @@ endif()
# General flags
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include(compile_flags/sdl)
include(compile_flags/os_flags)
include(compile_flags/sanitizer)
@@ -183,7 +183,6 @@ endfunction()
#
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
# to allows to override CMAKE_CXX_STANDARD from command line
if(NOT DEFINED CMAKE_CXX_STANDARD)
@@ -1,17 +1,9 @@
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
include(CheckCXXCompilerFlag)
if (ENABLE_SANITIZER OR ENABLE_THREAD_SANITIZER)
# This is workaround for https://gitlab.kitware.com/cmake/cmake/-/issues/16609.
# It ensures pthread is searched without ASAN linking.
# Line bellow must be before adding -fsanitize=address or -fsanitize=thread to
# build options for the trick to work.
find_package(Threads REQUIRED)
endif()
if (ENABLE_SANITIZER)
set(SANITIZER_COMPILER_FLAGS "-g -fsanitize=address -fno-omit-frame-pointer")
CHECK_CXX_COMPILER_FLAG("-fsanitize-recover=address" SANITIZE_RECOVER_SUPPORTED)
-2
View File
@@ -13,8 +13,6 @@ include(cmake/features.cmake)
# resolving dependencies for the project
include(cmake/dependencies.cmake)
find_package(Threads REQUIRED)
function(ie_developer_export_targets)
openvino_developer_export_targets(COMPONENT inference_engine TARGETS ${ARGN})
endfunction()
-4
View File
@@ -126,8 +126,4 @@ if (ENABLE_GNA)
endif()
endif()
if (ENABLE_SPEECH_DEMO)
add_definitions(-DENABLE_SPEECH_DEMO)
endif()
print_enabled_features()
@@ -1,6 +1,21 @@
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
#
# FindIE
# ------
#
# This will define the following variables:
#
# InferenceEngine_FOUND - True if the system has the Inference Engine library
# InferenceEngine_INCLUDE_DIRS - Inference Engine include directories
# InferenceEngine_LIBRARIES - Inference Engine libraries
#
# and the following imported targets:
#
# IE::inference_engine - The Inference Engine library
# IE::inference_engine_c_api - The Inference Engine C API library
#
if(DEFINED IE_MAIN_SOURCE_DIR AND TARGET inference_engine)
set(InferenceEngine_LIBRARIES inference_engine inference_engine_c_api)
@@ -12,14 +27,11 @@ if(DEFINED IE_MAIN_SOURCE_DIR AND TARGET inference_engine)
endif()
else()
include("${CMAKE_CURRENT_LIST_DIR}/inference_engine_targets.cmake")
if(NOT MSVC)
set_target_properties(IE::inference_engine PROPERTIES INTERFACE_COMPILE_OPTIONS "-Wno-error=deprecated-declarations")
endif()
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)
set (ie_options THREADING)
load_cache("${cache_path}" READ_WITH_PREFIX "" ${ie_options})
message(STATUS "The following CMake options are exported from the Inference Engine build")
message(STATUS "The following CMake options are exported from the Inference Engine build tree")
message("")
foreach(option IN LISTS ie_options)
message(" ${option}: ${${option}}")
@@ -42,4 +54,9 @@ else()
INTERFACE_LINK_OPTIONS "-Wl,--allow-shlib-undefined")
endif()
endforeach()
if(NOT MSVC)
set_target_properties(${InferenceEngine_LIBRARIES} PROPERTIES
INTERFACE_COMPILE_OPTIONS "-Wno-error=deprecated-declarations")
endif()
endif()
@@ -1,34 +1,29 @@
# Copyright (C) 2018-2020 Intel Corporation
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
# TODO: remove after changing [private plugins]
set(OpenVINO_MAIN_SOURCE_DIR "@OpenVINO_MAIN_SOURCE_DIR@") # KMB, HDDL
set(IE_MAIN_SOURCE_DIR "@IE_MAIN_SOURCE_DIR@") # KMB, HDDL
set(OpenVINO_MAIN_SOURCE_DIR "@OpenVINO_MAIN_SOURCE_DIR@") # KMB
set(IE_MAIN_SOURCE_DIR "@IE_MAIN_SOURCE_DIR@") # HDDL
# Variables to export in plugin's projects
set(ie_options "@IE_OPTIONS@;CMAKE_BUILD_TYPE;CMAKE_SKIP_RPATH")
file(TO_CMAKE_PATH "${CMAKE_CURRENT_LIST_DIR}" cache_path)
foreach(option IN LISTS ie_options)
if(NOT DEFINED "${option}")
load_cache("${cache_path}" READ_WITH_PREFIX "" ${option})
endif()
endforeach()
message(STATUS "The following CMake options are exported from Inference Engine Developer package")
message("")
foreach(option IN LISTS ie_options)
if(NOT DEFINED "${option}")
load_cache("${cache_path}" READ_WITH_PREFIX "" ${option})
endif()
message(" ${option}: ${${option}}")
endforeach()
message("")
# for samples in 3rd party projects
set(gflags_DIR "@gflags_BINARY_DIR@")
# GNA lib dir
set(GNA "@GNA@")
# Targets
if(USE_SYSTEM_PUGIXML)
@@ -40,7 +35,6 @@ foreach(component @openvino_export_components@)
include("${CMAKE_CURRENT_LIST_DIR}/${component}_dev_targets.cmake")
endforeach()
get_target_property(InferenceEngine_INCLUDE_DIRS IE::inference_engine INTERFACE_INCLUDE_DIRECTORIES)
set(InferenceEngine_LIBRARIES IE::inference_engine)
#
@@ -75,5 +69,3 @@ if (THREADING STREQUAL "TBB" OR THREADING STREQUAL "TBB_AUTO")
load_cache("${cache_path}" READ_WITH_PREFIX "" TBB_DIR)
find_package(TBB)
endif()
find_package(Threads REQUIRED)
@@ -1,31 +0,0 @@
@echo off
:: Copyright (C) 2018-2020 Intel Corporation
:: SPDX-License-Identifier: Apache-2.0
pushd ..\..
if not exist "vs2017x64" (
mkdir "vs2017x64"
)
cmake -E chdir "vs2017x64" cmake -G "Visual Studio 15 2017 Win64" -T "Intel C++ Compiler 18.0" -DOS_FOLDER=ON ^
-DENABLE_MYRIAD=OFF -DENABLE_VPU=OFF -DENABLE_GNA=ON -DENABLE_CLDNN=OFF ^
-DENABLE_OPENCV=ON -DENABLE_MKL_DNN=ON ^
-DVERBOSE_BUILD=ON -DENABLE_TESTS=ON -DTHREADING=TBB ..
chdir
cd "vs2017x64\thirdparty\"
"C:\Program Files (x86)\Common Files\Intel\shared files\ia32\Bin\ICProjConvert180.exe" mkldnn.vcxproj /IC
chdir
cd "..\src\mkldnn_plugin"
"C:\Program Files (x86)\Common Files\Intel\shared files\ia32\Bin\ICProjConvert180.exe" MKLDNNPlugin.vcxproj /IC
"C:\Program Files (x86)\Common Files\Intel\shared files\ia32\Bin\ICProjConvert180.exe" test_MKLDNNPlugin.vcxproj /IC
chdir
cd "..\..\tests\unit"
"C:\Program Files (x86)\Common Files\Intel\shared files\ia32\Bin\ICProjConvert180.exe" InferenceEngineUnitTests.vcxproj /IC
popd
pause
@@ -20,11 +20,6 @@ target_link_libraries(${TARGET_NAME} PUBLIC
ieTestHelpers
)
if(UNIX)
find_package(Threads REQUIRED)
target_link_libraries(${TARGET_NAME} PRIVATE Threads::Threads)
endif()
target_link_libraries(${TARGET_NAME} PUBLIC gmock)
target_include_directories(${TARGET_NAME} PUBLIC
@@ -17,8 +17,6 @@
disable_deprecated_warnings()
function(add_perfcheck_target TARGET_NAME PLUGIN_NAME)
find_package(Threads REQUIRED)
file(GLOB SOURCES *.cpp)
add_executable(${TARGET_NAME} ${SOURCES})
@@ -21,7 +21,6 @@ file (GLOB HDR
add_executable(${TARGET_NAME} ${HDR} ${SRC})
find_package(gflags REQUIRED)
find_package(Threads REQUIRED)
target_link_libraries(${TARGET_NAME}
IE::gtest
@@ -21,7 +21,6 @@ file (GLOB HDR
add_executable(${TARGET_NAME} ${HDR} ${SRC})
find_package(gflags REQUIRED)
find_package(Threads REQUIRED)
target_link_libraries(${TARGET_NAME}
IE::gtest