Try to improve gflags

This commit is contained in:
Ilya Lavrenov 2022-04-02 19:23:15 +03:00
parent 81aa7ccc38
commit 56dad4d12a
4 changed files with 35 additions and 19 deletions

View File

@ -30,7 +30,7 @@ function(ov_generate_dev_package_config)
# dummy check that OpenCV is here
find_package(OpenCV QUIET)
set(all_dev_targets gflags ov_runtime_libraries)
set(all_dev_targets ov_runtime_libraries)
foreach(component IN LISTS openvino_export_components)
string(FIND "${component}" "_legacy" index)
if (index EQUAL -1)

View File

@ -108,8 +108,11 @@ endif()
# TODO: add find_package calls for gflags, zlib and json
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags" AND
NOT DEFINED OpenVINO_SOURCE_DIR)
find_package(gflags QUIET COMPONENTS nothreads_shared)
if(gflags_FOUND)
message(STATUS "gflags (${gflags_VERSION}) are found at ${gflags_DIR}")
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/gflags" AND NOT TARGET gflags_nothreads_shared)
add_subdirectory(thirdparty/gflags EXCLUDE_FROM_ALL)
endif()
@ -217,12 +220,10 @@ macro(ie_add_sample)
target_link_libraries(${IE_SAMPLE_NAME} PRIVATE gflags)
endif()
install(
TARGETS ${IE_SAMPLE_NAME}
RUNTIME DESTINATION samples_bin/
COMPONENT samples_bin
EXCLUDE_FROM_ALL
)
install(TARGETS ${IE_SAMPLE_NAME}
RUNTIME DESTINATION samples_bin/
COMPONENT samples_bin
EXCLUDE_FROM_ALL)
# create global target with all samples / demo apps
if(NOT TARGET ie_samples)

View File

@ -65,7 +65,12 @@ ov_install_static_lib(fluid openvino_common)
#
add_subdirectory(gflags EXCLUDE_FROM_ALL)
openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags)
if(NOT DEFINED gflags_DIR)
# export only target built in current source tree;
# imported target (found via find_package) cannot be exported
openvino_developer_export_targets(COMPONENT openvino_common TARGETS gflags)
endif()
#
# Google Tests framework
@ -145,9 +150,13 @@ ov_install_static_lib(nlohmann_json_schema_validator openvino_common)
# Install
#
if(NOT CPACK_GENERATOR STREQUAL "DEB")
if(CPACK_GENERATOR STREQUAL "DEB")
# These libraries are dependencies for openvino-samples-2022.1 package
if(NOT DEFINED gflags_DIR)
message(FATAL_ERROR "gflags must be used as a debian package")
endif()
else()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/gflags
DESTINATION ${OV_CPACK_SAMPLESDIR}/cpp/thirdparty
COMPONENT ${OV_CPACK_COMP_CPP_SAMPLES}

View File

@ -2,12 +2,18 @@
# SPDX-License-Identifier: Apache-2.0
#
set(GFLAGS_IS_SUBPROJECT TRUE)
set(HAVE_SYS_STAT_H 1)
set(HAVE_INTTYPES_H 1)
set(INTTYPES_FORMAT C99)
set(BUILD_TESTING OFF)
set(BUILD_SHARED_LIBS OFF)
find_package(gflags QUIET COMPONENTS nothreads_shared)
add_subdirectory(gflags EXCLUDE_FROM_ALL)
set_target_properties(gflags_nothreads_static PROPERTIES FOLDER thirdparty)
if(gflags_FOUND)
message(STATUS "gflags (${gflags_VERSION}) are found at ${gflags_DIR}")
else()
set(GFLAGS_IS_SUBPROJECT TRUE)
set(HAVE_SYS_STAT_H 1)
set(HAVE_INTTYPES_H 1)
set(INTTYPES_FORMAT C99)
set(BUILD_TESTING OFF)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(gflags EXCLUDE_FROM_ALL)
set_target_properties(gflags_nothreads_static PROPERTIES FOLDER thirdparty)
endif()