Use system gflags only in samples (#18478)

This commit is contained in:
Ilya Lavrenov 2023-07-13 20:45:22 +04:00 committed by GitHub
parent 3daa387692
commit bca3f3e441
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 56 deletions

View File

@ -147,6 +147,7 @@ jobs:
- script: |
git submodule update --init -- $(OPENVINO_REPO_DIR)/src/plugins
git submodule update --init -- $(OPENVINO_REPO_DIR)/thirdparty/gtest
git submodule update --init -- $(OPENVINO_REPO_DIR)/thirdparty/gflags
git submodule update --init -- $(OPENVINO_REPO_DIR)/thirdparty/open_model_zoo
displayName: 'Init submodules for non Conan dependencies'

View File

@ -100,12 +100,11 @@ endif()
if(TARGET gflags)
set(GFLAGS_TARGET gflags)
elseif(gflags_required)
if(EXISTS /etc/debian_version)
set(gflags_component nothreads_static)
else()
set(gflags_component shared)
endif()
find_package(gflags QUIET OPTIONAL_COMPONENTS ${gflags_component})
set(GFLAGS_USE_TARGET_NAMESPACE ON)
set(GFLAGS_SHARED OFF)
set(GFLAGS_NOTHREADS ON)
find_package(gflags QUIET)
if(gflags_FOUND)
if(TARGET ${GFLAGS_TARGET})
# nothing

View File

@ -4,8 +4,6 @@
if(CMAKE_TOOLCHAIN_FILE MATCHES "vcpkg" OR DEFINED VCPKG_VERBOSE)
set(OV_VCPKG_BUILD ON)
elseif(CMAKE_TOOLCHAIN_FILE MATCHES "conan_toolchain" OR DEFINED CONAN_EXPORTED)
set(OV_CONAN_BUILD)
endif()
set(_old_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
@ -369,51 +367,8 @@ endif()
#
if(ENABLE_SAMPLES OR ENABLE_TESTS)
if(OV_VCPKG_BUILD OR OV_CONAN_BUILD)
# vcpkg contains only libs compiled with threads
# conan case
find_package(gflags QUIET)
elseif(APPLE OR WIN32)
# on Windows and macOS we don't use gflags, because will be dynamically linked
elseif(CMAKE_HOST_LINUX AND LINUX)
if(OV_OS_RHEL)
set(gflag_component nothreads_shared)
elseif(OV_OS_DEBIAN)
set(gflag_component nothreads_static)
endif()
find_package(gflags QUIET OPTIONAL_COMPONENTS ${gflag_component})
endif()
if(gflags_FOUND)
if(TARGET gflags)
# no extra steps
elseif(TARGET gflags_nothreads-static)
# Debian 9: gflag_component is ignored
set(gflags_target gflags_nothreads-static)
elseif(TARGET gflags_nothreads-shared)
# CentOS / RHEL / Fedora case
set(gflags_target gflags_nothreads-shared)
elseif(TARGET ${GFLAGS_TARGET})
set(gflags_target ${GFLAGS_TARGET})
else()
message(FATAL_ERROR "Internal error: failed to find imported target 'gflags' using '${gflag_component}' component")
endif()
if(gflags_target)
if(OV_PkgConfig_VISILITY)
# need to set GLOBAL visibility in order to create ALIAS for this target
set_target_properties(${gflags_target} PROPERTIES IMPORTED_GLOBAL ON)
endif()
add_library(gflags ALIAS ${gflags_target})
endif()
message(STATUS "gflags (${gflags_VERSION}) is found at ${gflags_DIR} using '${gflag_component}' component")
endif()
if(NOT TARGET gflags)
add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags)
endif()
add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags)
endif()
#
@ -635,9 +590,6 @@ endif()
if(CPACK_GENERATOR MATCHES "^(DEB|RPM|CONDA-FORGE|BREW|CONAN|VCPKG)$")
# These libraries are dependencies for openvino-samples package
if(ENABLE_SAMPLES OR ENABLE_TESTS)
if(NOT gflags_FOUND AND CPACK_GENERATOR MATCHES "^(DEB|RPM)$")
message(FATAL_ERROR "gflags must be used as a ${CPACK_GENERATOR} package. Install libgflags-dev / gflags-devel")
endif()
if(NOT (zlib_FOUND OR ZLIB_FOUND))
message(FATAL_ERROR "zlib must be used as a ${CPACK_GENERATOR} package. Install zlib1g-dev / zlib-devel")
endif()