2020-02-11 23:04:29 +00:00
|
|
|
# Copyright (C) 2011-2020 (see AUTHORS file for a list of contributors)
|
|
|
|
#
|
|
|
|
# GNSS-SDR is a software-defined Global Navigation Satellite Systems receiver
|
2018-12-14 17:59:36 +00:00
|
|
|
#
|
|
|
|
# This file is part of GNSS-SDR.
|
|
|
|
#
|
2020-02-08 00:20:02 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2018-12-14 17:59:36 +00:00
|
|
|
|
|
|
|
# - Try to find GFlags
|
|
|
|
#
|
|
|
|
# The following CMake and environment variables are optionally searched
|
|
|
|
# for defaults:
|
|
|
|
# GFLAGS_ROOT: Base directory where all GFlags components are found
|
|
|
|
#
|
|
|
|
# The following are set after configuration is done:
|
|
|
|
# GFlags_FOUND
|
|
|
|
# GFlags_INCLUDE_DIRS
|
|
|
|
# GFlags_LIBS
|
|
|
|
# GFlags_LIBRARY_DIRS
|
2019-02-03 18:24:44 +00:00
|
|
|
#
|
|
|
|
# Provides the following imported target:
|
|
|
|
# Gflags::gflags
|
|
|
|
#
|
2018-12-14 17:59:36 +00:00
|
|
|
|
2019-06-21 00:49:41 +00:00
|
|
|
|
|
|
|
if(NOT COMMAND feature_summary)
|
|
|
|
include(FeatureSummary)
|
|
|
|
endif()
|
|
|
|
|
2020-02-29 13:33:09 +00:00
|
|
|
if(NOT GFLAGS_ROOT)
|
|
|
|
set(GFLAGS_ROOT_USER_PROVIDED /usr/local)
|
|
|
|
else()
|
|
|
|
set(GFLAGS_ROOT_USER_PROVIDED ${GFLAGS_ROOT})
|
|
|
|
endif()
|
|
|
|
if(DEFINED ENV{GFLAGS_ROOT})
|
|
|
|
set(GFLAGS_ROOT_USER_PROVIDED
|
|
|
|
${GFLAGS_ROOT_USER_PROVIDED}
|
|
|
|
$ENV{GFLAGS_ROOT}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2018-12-14 17:59:36 +00:00
|
|
|
if(APPLE)
|
|
|
|
find_path(GFlags_ROOT_DIR
|
2020-02-29 13:33:09 +00:00
|
|
|
libgflags.dylib
|
|
|
|
PATHS
|
|
|
|
${GFLAGS_ROOT_USER_PROVIDED}/lib
|
|
|
|
/usr/local/lib
|
|
|
|
/opt/local/lib
|
2018-12-14 17:59:36 +00:00
|
|
|
)
|
|
|
|
else()
|
|
|
|
find_path(GFlags_ROOT_DIR
|
2020-02-29 13:33:09 +00:00
|
|
|
libgflags.so
|
|
|
|
PATHS
|
|
|
|
${GFLAGS_ROOT_USER_PROVIDED}/lib
|
|
|
|
${GFLAGS_ROOT_USER_PROVIDED}/lib64
|
|
|
|
/usr/lib
|
|
|
|
/usr/lib64
|
|
|
|
/usr/lib/x86_64-linux-gnu
|
|
|
|
/usr/lib/i386-linux-gnu
|
|
|
|
/usr/lib/arm-linux-gnueabihf
|
|
|
|
/usr/lib/arm-linux-gnueabi
|
|
|
|
/usr/lib/aarch64-linux-gnu
|
|
|
|
/usr/lib/mipsel-linux-gnu
|
|
|
|
/usr/lib/mips-linux-gnu
|
|
|
|
/usr/lib/mips64el-linux-gnuabi64
|
|
|
|
/usr/lib/powerpc-linux-gnu
|
|
|
|
/usr/lib/powerpc64-linux-gnu
|
|
|
|
/usr/lib/powerpc64le-linux-gnu
|
|
|
|
/usr/lib/powerpc-linux-gnuspe
|
|
|
|
/usr/lib/hppa-linux-gnu
|
|
|
|
/usr/lib/s390x-linux-gnu
|
|
|
|
/usr/lib/i386-gnu
|
|
|
|
/usr/lib/hppa-linux-gnu
|
|
|
|
/usr/lib/x86_64-kfreebsd-gnu
|
|
|
|
/usr/lib/i386-kfreebsd-gnu
|
|
|
|
/usr/lib/m68k-linux-gnu
|
|
|
|
/usr/lib/sh4-linux-gnu
|
|
|
|
/usr/lib/sparc64-linux-gnu
|
|
|
|
/usr/lib/x86_64-linux-gnux32
|
|
|
|
/usr/lib/alpha-linux-gnu
|
|
|
|
/usr/lib/riscv64-linux-gnu
|
|
|
|
/usr/local/lib
|
|
|
|
/usr/local/lib64
|
|
|
|
/opt/local/lib
|
2018-12-14 17:59:36 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(GFlags_ROOT_DIR)
|
|
|
|
# We are testing only a couple of files in the include directories
|
|
|
|
find_path(GFlags_INCLUDE_DIRS
|
2020-02-29 13:33:09 +00:00
|
|
|
gflags/gflags.h
|
|
|
|
PATHS
|
|
|
|
${GFlags_ROOT_DIR}/src
|
|
|
|
${GFLAGS_ROOT_USER_PROVIDED}/include
|
|
|
|
/usr/include
|
|
|
|
/usr/local/include
|
|
|
|
/opt/local/include
|
2018-12-14 17:59:36 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# Find the libraries
|
|
|
|
set(GFlags_LIBRARY_DIRS ${GFlags_ROOT_DIR})
|
|
|
|
|
|
|
|
find_library(GFlags_lib gflags ${GFlags_LIBRARY_DIRS})
|
|
|
|
if(EXISTS ${GFlags_INCLUDE_DIRS}/gflags/gflags_gflags.h)
|
2020-02-29 13:33:09 +00:00
|
|
|
set(GFLAGS_GREATER_20 TRUE)
|
2018-12-14 17:59:36 +00:00
|
|
|
else()
|
2020-02-29 13:33:09 +00:00
|
|
|
set(GFLAGS_GREATER_20 FALSE)
|
2018-12-14 17:59:36 +00:00
|
|
|
endif()
|
|
|
|
message(STATUS "gflags library found at ${GFlags_lib}")
|
|
|
|
set(GFlags_LIBS ${GFlags_lib})
|
|
|
|
set(GFlags_FOUND true)
|
|
|
|
mark_as_advanced(GFlags_INCLUDE_DIRS)
|
|
|
|
else()
|
|
|
|
message(STATUS "Cannot find gflags")
|
|
|
|
set(GFlags_FOUND false)
|
|
|
|
endif()
|
|
|
|
|
2020-08-13 18:54:22 +00:00
|
|
|
if(GFlags_LIBS AND GFlags_INCLUDE_DIRS)
|
2020-02-29 13:33:09 +00:00
|
|
|
if(NOT PACKAGE_VERSION)
|
|
|
|
set(PACKAGE_VERSION "")
|
|
|
|
endif()
|
2019-06-27 06:47:09 +00:00
|
|
|
set(OLD_PACKAGE_VERSION ${PACKAGE_VERSION})
|
|
|
|
unset(PACKAGE_VERSION)
|
2019-06-19 06:42:44 +00:00
|
|
|
list(GET GFlags_LIBS 0 FIRST_DIR)
|
|
|
|
get_filename_component(GFlags_LIBS_DIR ${FIRST_DIR} DIRECTORY)
|
|
|
|
if(EXISTS ${GFlags_LIBS_DIR}/cmake/gflags/gflags-config-version.cmake)
|
|
|
|
include(${GFlags_LIBS_DIR}/cmake/gflags/gflags-config-version.cmake)
|
|
|
|
endif()
|
2020-08-13 18:54:22 +00:00
|
|
|
if(NOT PACKAGE_VERSION)
|
|
|
|
if(EXISTS ${GFlags_INCLUDE_DIRS}/google/gflags.h)
|
|
|
|
set(PACKAGE_VERSION "2.0")
|
|
|
|
endif()
|
|
|
|
endif()
|
2019-06-19 06:42:44 +00:00
|
|
|
if(PACKAGE_VERSION)
|
|
|
|
set(GFLAGS_VERSION ${PACKAGE_VERSION})
|
2019-06-21 00:49:41 +00:00
|
|
|
set_package_properties(GFLAGS PROPERTIES
|
|
|
|
DESCRIPTION "C++ library that implements commandline flags processing (found: v${GFLAGS_VERSION})"
|
|
|
|
)
|
|
|
|
else()
|
|
|
|
set_package_properties(GFLAGS PROPERTIES
|
|
|
|
DESCRIPTION "C++ library that implements commandline flags processing"
|
|
|
|
)
|
2019-06-19 06:42:44 +00:00
|
|
|
endif()
|
2019-06-27 06:47:09 +00:00
|
|
|
set(PACKAGE_VERSION ${OLD_PACKAGE_VERSION})
|
2019-06-21 00:49:41 +00:00
|
|
|
else()
|
|
|
|
set_package_properties(GFLAGS PROPERTIES
|
|
|
|
DESCRIPTION "C++ library that implements commandline flags processing"
|
|
|
|
)
|
2019-06-19 06:42:44 +00:00
|
|
|
endif()
|
|
|
|
|
2019-06-21 00:49:41 +00:00
|
|
|
set_package_properties(GFLAGS PROPERTIES
|
|
|
|
URL "https://github.com/gflags/gflags"
|
|
|
|
)
|
|
|
|
|
2020-08-13 18:54:22 +00:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package_handle_standard_args(GFLAGS DEFAULT_MSG GFlags_LIBS GFlags_INCLUDE_DIRS)
|
|
|
|
|
|
|
|
if(GFLAGS_VERSION)
|
|
|
|
if(${GFLAGS_VERSION} VERSION_LESS "${GNSSSDR_GFLAGS_MIN_VERSION}")
|
|
|
|
set(GFLAGS_FOUND FALSE)
|
|
|
|
unset(GFlags_LIBS CACHE)
|
|
|
|
unset(GFlags_INCLUDE_DIRS CACHE)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2019-02-03 18:24:44 +00:00
|
|
|
if(GFLAGS_FOUND AND NOT TARGET Gflags::gflags)
|
|
|
|
add_library(Gflags::gflags SHARED IMPORTED)
|
|
|
|
set_target_properties(Gflags::gflags PROPERTIES
|
|
|
|
IMPORTED_LINK_INTERFACE_LANGUAGES "CXX"
|
|
|
|
IMPORTED_LOCATION "${GFlags_LIBS}"
|
|
|
|
INTERFACE_INCLUDE_DIRECTORIES "${GFlags_INCLUDE_DIRS}"
|
|
|
|
INTERFACE_LINK_LIBRARIES "${GFlags_LIBS}"
|
|
|
|
)
|
|
|
|
endif()
|