diff --git a/CMakeLists.txt b/CMakeLists.txt index b582d21e9..9ea8e75e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1046,11 +1046,13 @@ set(LOCAL_GFLAGS false) find_package(GFLAGS) set_package_properties(GFLAGS PROPERTIES URL "https://github.com/gflags/gflags" - DESCRIPTION "C++ library that implements commandline flags processing" PURPOSE "Used for commandline flags management." TYPE REQUIRED ) if(NOT GFLAGS_FOUND) + set_package_properties(GFLAGS PROPERTIES + DESCRIPTION "C++ library that implements commandline flags processing" + ) message(STATUS " gflags library has not been found.") message(STATUS " gflags v${GNSSSDR_GFLAGS_LOCAL_VERSION} will be downloaded and built automatically ") message(STATUS " when doing 'make'.") @@ -1109,6 +1111,16 @@ if(NOT GFLAGS_FOUND) set_package_properties(GFLAGS PROPERTIES PURPOSE "Gflags v${GNSSSDR_GFLAGS_LOCAL_VERSION} will be downloaded and built when doing '${CMAKE_MAKE_PROGRAM_PRETTY_NAME}'." ) +else() + if(GFLAGS_VERSION) + 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" + ) + endif() endif() @@ -1124,11 +1136,13 @@ if(NOT ${ENABLE_OWN_GLOG}) endif() set_package_properties(GLOG PROPERTIES URL "https://github.com/google/glog" - DESCRIPTION "C++ implementation of the Google logging module" PURPOSE "Used for runtime internal logging." TYPE REQUIRED ) if(NOT GLOG_FOUND OR ${LOCAL_GFLAGS}) + set_package_properties(GLOG PROPERTIES + DESCRIPTION "C++ implementation of the Google logging module" + ) message(STATUS " glog library has not been found") if(NOT GFLAGS_FOUND) message(STATUS " or it is likely not linked to gflags.") @@ -1285,6 +1299,16 @@ ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/glog/glog-${GNSSSDR_GLOG_LOCAL_VERSION}/c set_package_properties(GLOG PROPERTIES PURPOSE "Glog v${GNSSSDR_GLOG_LOCAL_VERSION} will be downloaded and built when doing 'make'." ) +else() + if(GLOG_VERSION) + set_package_properties(GLOG PROPERTIES + DESCRIPTION "C++ implementation of the Google logging module (found: v${GLOG_VERSION})" + ) + else() + set_package_properties(GLOG PROPERTIES + DESCRIPTION "C++ implementation of the Google logging module" + ) + endif() endif() if(NOT ENABLE_LOG) diff --git a/cmake/Modules/FindGFLAGS.cmake b/cmake/Modules/FindGFLAGS.cmake index db1f9d891..5de8d4247 100644 --- a/cmake/Modules/FindGFLAGS.cmake +++ b/cmake/Modules/FindGFLAGS.cmake @@ -111,6 +111,17 @@ endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GFLAGS DEFAULT_MSG GFlags_LIBS GFlags_INCLUDE_DIRS) +if(GFLAGS_FOUND) + 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() + if(PACKAGE_VERSION) + set(GFLAGS_VERSION ${PACKAGE_VERSION}) + endif() +endif() + if(GFLAGS_FOUND AND NOT TARGET Gflags::gflags) add_library(Gflags::gflags SHARED IMPORTED) set_target_properties(Gflags::gflags PROPERTIES diff --git a/cmake/Modules/FindGLOG.cmake b/cmake/Modules/FindGLOG.cmake index b85339195..2ac5ab7fb 100644 --- a/cmake/Modules/FindGLOG.cmake +++ b/cmake/Modules/FindGLOG.cmake @@ -41,6 +41,9 @@ else() set(LIB_PATHS ${GLOG_ROOT} ${GLOG_ROOT}/lib) endif() +include(FindPkgConfig) +pkg_check_modules(PC_GLOG libglog) + macro(_FIND_GLOG_LIBRARIES _var) find_library(${_var} NAMES ${ARGN} @@ -75,6 +78,7 @@ macro(_FIND_GLOG_LIBRARIES _var) $ENV{GLOG_ROOT}/lib ${GLOG_ROOT}/lib64 $ENV{GLOG_ROOT}/lib64 + ${PC_GLOG_LIBDIR} PATH_SUFFIXES lib ) mark_as_advanced(${_var}) @@ -94,6 +98,7 @@ if(MSVC) PATHS ${GLOG_ROOT}/src/windows ${GLOG_ROOT}/src/windows/glog + ${PC_GLOG_INCLUDEDIR} ) else() # Linux/OS X builds @@ -102,6 +107,7 @@ else() ${GLOG_ROOT}/include/glog /usr/include/glog /opt/local/include/glog # default location in Macports + ${PC_GLOG_INCLUDEDIR} ) endif() @@ -118,15 +124,18 @@ else() endif() endif() -if(GLOG_FOUND) - message(STATUS "glog library found at ${GLOG_LIBRARIES}") -endif() - # handle the QUIETLY and REQUIRED arguments and set GLOG_FOUND to TRUE if # all listed variables are TRUE include(FindPackageHandleStandardArgs) find_package_handle_standard_args(GLOG DEFAULT_MSG GLOG_LIBRARIES) +if(GLOG_FOUND) + message(STATUS "glog library found at ${GLOG_LIBRARIES}") + if(PC_GLOG_VERSION) + set(GLOG_VERSION ${PC_GLOG_VERSION}) + endif() +endif() + if(MSVC) string(REGEX REPLACE "/glog$" "" VAR_WITHOUT ${GLOG_INCLUDE_DIR}) string(REGEX REPLACE "/windows$" "" VAR_WITHOUT ${VAR_WITHOUT})