Skip to content

Commit

Permalink
Respect COMPONENTS in InferenceEngineConfig.cmake (#5857)
Browse files Browse the repository at this point in the history
* Added note abour custom version of find_dependency

* Warning about improper version in find_package()

* Removed ENABLE_ALTERNATIVE_TEMP

* Respect COMPONENTS in InferenceEngine cmake config

* Added Jira ticket #
  • Loading branch information
ilya-lavrenov authored May 27, 2021
1 parent f450f61 commit c470024
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 24 deletions.
3 changes: 0 additions & 3 deletions cmake/developer_package/IEDevScriptsConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ function(set_temp_directory temp_variable source_tree_dir)
if (DEFINED ENV{DL_SDK_TEMP} AND NOT $ENV{DL_SDK_TEMP} STREQUAL "")
message(STATUS "DL_SDK_TEMP environment is set : $ENV{DL_SDK_TEMP}")
file(TO_CMAKE_PATH $ENV{DL_SDK_TEMP} temp)
if (ENABLE_ALTERNATIVE_TEMP)
set(ALTERNATIVE_PATH ${source_tree_dir}/temp)
endif()
else ()
set(temp ${source_tree_dir}/temp)
endif()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ function (CheckOrDownloadAndExtract component RELATIVE_URL archive_name unpacked
#path exists, so we would like to check what was unpacked version
set (version_file ${unpacked_path}/ie_dependency.info)

if (NOT EXISTS ${version_file} AND NOT ${ENABLE_ALTERNATIVE_TEMP})
if (NOT EXISTS ${version_file})
clean_message(FATAL_ERROR "error: Dependency doesn't contain version file. Please select actions: \n"
"if you are not sure about your FS dependency - remove it : \n"
"\trm -rf ${unpacked_path}\n"
Expand Down
2 changes: 0 additions & 2 deletions cmake/developer_package/features.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ ie_option (VERBOSE_BUILD "shows extra information about build" OFF)

ie_option (ENABLE_UNSAFE_LOCATIONS "skip check for MD5 for dependency" OFF)

ie_option (ENABLE_ALTERNATIVE_TEMP "in case of dependency conflict, to avoid modification in master, use local copy of dependency" OFF)

ie_dependent_option (ENABLE_FUZZING "instrument build for fuzzing" OFF "CMAKE_CXX_COMPILER_ID MATCHES ^(Apple)?Clang$; NOT WIN32" OFF)

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ set(PACKAGE_VERSION_COMPATIBLE False)
# Compatibility with old versioning for 2.x
if(PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL 2)
set(PACKAGE_VERSION_COMPATIBLE True)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
message(WARNING "Inference Engine versioning has changed. Use ${PACKAGE_VERSION} instead of ${PACKAGE_FIND_VERSION}")
endif()
endif()

if(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
Expand Down
64 changes: 49 additions & 15 deletions inference-engine/cmake/templates/InferenceEngineConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Inference Engine cmake config
# ------
#
# This will define the following variables:
# This config defines the following variables:
#
# InferenceEngine_FOUND - True if the system has the Inference Engine library
# InferenceEngine_INCLUDE_DIRS - Inference Engine include directories
Expand All @@ -25,6 +25,11 @@

@PACKAGE_INIT@

#
# Common functions
#

# we have to use our own version of find_dependency because of support cmake 3.7
macro(_ie_find_dependency dep)
set(cmake_fd_quiet_arg)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
Expand Down Expand Up @@ -56,6 +61,22 @@ macro(_ie_find_dependency dep)
set(cmake_fd_quiet_arg)
endmacro()

function(_ie_target_no_deprecation_error)
if(NOT MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(flags "-diag-warning=1786")
else()
set(flags "-Wno-error=deprecated-declarations")
endif()

set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
endif()
endfunction()

#
# Inference Engine config
#

# need to store current PACKAGE_PREFIX_DIR, because it's overwritten by ngraph one
set(IE_PACKAGE_PREFIX_DIR "${PACKAGE_PREFIX_DIR}")

Expand All @@ -78,29 +99,42 @@ _ie_find_dependency(ngraph
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)

function(_ie_target_no_deprecation_error)
if(NOT MSVC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(flags "-diag-warning=1786")
else()
set(flags "-Wno-error=deprecated-declarations")
if(NOT TARGET inference_engine)
set(_ie_as_external_package ON)
include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake")
endif()

# mark components as available
foreach(comp inference_engine inference_engine_c_api)
set(${CMAKE_FIND_PACKAGE_NAME}_${comp}_FOUND ON)
endforeach()

if(NOT ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS inference_engine inference_engine_c_api)
endif()

unset(InferenceEngine_LIBRARIES)
foreach(comp IN LISTS ${CMAKE_FIND_PACKAGE_NAME}_FIND_COMPONENTS)
# check if the component is available
if(${CMAKE_FIND_PACKAGE_NAME}_${comp}_FOUND)
set(pcomp ${comp})
if(_ie_as_external_package)
set(pcomp IE::${comp})
endif()

set_target_properties(${ARGV} PROPERTIES INTERFACE_COMPILE_OPTIONS ${flags})
list(APPEND InferenceEngine_LIBRARIES ${pcomp})
endif()
endfunction()
endforeach()

if(TARGET inference_engine)
set(InferenceEngine_LIBRARIES inference_engine inference_engine_c_api)
else()
include("${CMAKE_CURRENT_LIST_DIR}/InferenceEngineTargets.cmake")
set(InferenceEngine_LIBRARIES IE::inference_engine IE::inference_engine_c_api)
if(_ie_as_external_package)
_ie_target_no_deprecation_error(${InferenceEngine_LIBRARIES})
endif()
unset(_ie_as_external_package)

# restore PACKAGE_PREFIX_DIR
set(PACKAGE_PREFIX_DIR ${IE_PACKAGE_PREFIX_DIR})
unset(IE_PACKAGE_PREFIX_DIR)

set_and_check(InferenceEngine_INCLUDE_DIRS "@PACKAGE_IE_INCLUDE_DIR@")

check_required_components(InferenceEngine)
check_required_components(${CMAKE_FIND_PACKAGE_NAME})
10 changes: 8 additions & 2 deletions inference-engine/samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()

find_package(InferenceEngine REQUIRED)

if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/common/utils")
add_subdirectory(common/utils)
endif()
Expand Down Expand Up @@ -220,6 +218,14 @@ macro(ie_add_sample)
set(folder_name c_samples)
endif()

if(c_sample)
set(ie_component inference_engine_c_api)
else()
set(ie_component inference_engine)
endif()

find_package(InferenceEngine REQUIRED COMPONENTS ${ie_component})

set_target_properties(${IE_SAMPLE_NAME} PROPERTIES FOLDER ${folder_name}
COMPILE_PDB_NAME ${IE_SAMPLE_NAME})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ std::vector<std::string> disabledTestPatterns() {
R"(.*BF16NetworkRestore1.*)",
R"(.*MobileNet_ssd_with_branching.*)",

// AUTO plugin and QueryNetwork
// TODO: 55656 AUTO plugin and QueryNetwork
R"(.*CoreThreading.*smoke_QueryNetwork.*targetDevice=AUTO_config.*)",
// TODO: 54718 Accuracy mismatch
R"(.*GroupDeconv_2D_DW_BF16.*K\(3\.3\)_S\(1\.1\).*primitive=jit_avx512_dw.*)",
Expand Down

0 comments on commit c470024

Please sign in to comment.