123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384 |
- macro(GLOG_RESET_FIND_LIBRARY_PREFIX)
- if (MSVC AND CALLERS_CMAKE_FIND_LIBRARY_PREFIXES)
- set(CMAKE_FIND_LIBRARY_PREFIXES "${CALLERS_CMAKE_FIND_LIBRARY_PREFIXES}")
- endif()
- endmacro(GLOG_RESET_FIND_LIBRARY_PREFIX)
- macro(GLOG_REPORT_NOT_FOUND REASON_MSG)
- unset(GLOG_FOUND)
- unset(GLOG_INCLUDE_DIRS)
- unset(GLOG_LIBRARIES)
-
-
- mark_as_advanced(CLEAR GLOG_INCLUDE_DIR
- GLOG_LIBRARY)
- glog_reset_find_library_prefix()
-
-
- if (Glog_FIND_QUIETLY)
- message(STATUS "Failed to find glog - " ${REASON_MSG} ${ARGN})
- elseif (Glog_FIND_REQUIRED)
- message(FATAL_ERROR "Failed to find glog - " ${REASON_MSG} ${ARGN})
- else()
-
-
- message("-- Failed to find glog - " ${REASON_MSG} ${ARGN})
- endif ()
- return()
- endmacro(GLOG_REPORT_NOT_FOUND)
- function(GLOG_MESSAGE)
- if (NOT Glog_FIND_QUIETLY)
- message(${ARGN})
- endif()
- endfunction()
- unset(GLOG_FOUND)
- if (NOT DEFINED GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION
- AND NOT GLOG_INCLUDE_DIR_HINTS
- AND NOT GLOG_LIBRARY_DIR_HINTS)
- glog_message(STATUS "No preference for use of exported glog CMake "
- "configuration set, and no hints for include/library directories provided. "
- "Defaulting to preferring an installed/exported glog CMake configuration "
- "if available.")
- set(GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION TRUE)
- endif()
- if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
- find_program(HOMEBREW_EXECUTABLE brew)
- mark_as_advanced(FORCE HOMEBREW_EXECUTABLE)
- if (HOMEBREW_EXECUTABLE)
-
- execute_process(COMMAND ${HOMEBREW_EXECUTABLE} --prefix
- OUTPUT_VARIABLE HOMEBREW_INSTALL_PREFIX
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- glog_message(STATUS "Detected Homebrew with install prefix: "
- "${HOMEBREW_INSTALL_PREFIX}, adding to CMake search paths.")
- list(APPEND GLOG_INCLUDE_DIR_HINTS "${HOMEBREW_INSTALL_PREFIX}/include")
- list(APPEND GLOG_LIBRARY_DIR_HINTS "${HOMEBREW_INSTALL_PREFIX}/lib")
- endif()
- endif()
- if (GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- find_package(glog QUIET
- NAMES google-glog glog
- HINTS ${glog_DIR} ${HOMEBREW_INSTALL_PREFIX}
- NO_MODULE
- NO_CMAKE_PACKAGE_REGISTRY
- NO_CMAKE_BUILDS_PATH)
- if (glog_FOUND)
- glog_message(STATUS "Found installed version of glog: ${glog_DIR}")
- else()
-
-
- glog_message(STATUS "Failed to find installed glog CMake configuration, "
- "searching for glog build directories exported with CMake.")
-
-
- find_package(glog QUIET
- NAMES google-glog glog
- NO_MODULE
- NO_CMAKE_BUILDS_PATH)
- if (glog_FOUND)
- glog_message(STATUS "Found exported glog build directory: ${glog_DIR}")
- endif(glog_FOUND)
- endif(glog_FOUND)
- set(FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION ${glog_FOUND})
- if (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION)
- glog_message(STATUS "Detected glog version: ${glog_VERSION}")
- set(GLOG_FOUND ${glog_FOUND})
-
- set(GLOG_INCLUDE_DIR "")
- set(GLOG_LIBRARY glog::glog)
- else (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION)
- glog_message(STATUS "Failed to find an installed/exported CMake "
- "configuration for glog, will perform search for installed glog "
- "components.")
- endif (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION)
- endif(GLOG_PREFER_EXPORTED_GLOG_CMAKE_CONFIGURATION)
- if (NOT GLOG_FOUND)
-
-
-
-
- if (MSVC)
-
-
- set(CALLERS_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
-
-
- set(CMAKE_FIND_LIBRARY_PREFIXES "lib" "" "${CMAKE_FIND_LIBRARY_PREFIXES}")
- endif (MSVC)
-
-
- list(APPEND GLOG_CHECK_INCLUDE_DIRS
- /usr/local/include
- /usr/local/homebrew/include
- /opt/local/var/macports/software
- /opt/local/include
- /usr/include)
-
- list(APPEND GLOG_CHECK_PATH_SUFFIXES
- glog/include
- glog/Include
- Glog/include
- Glog/Include
- google-glog/include
- google-glog/Include)
- list(APPEND GLOG_CHECK_LIBRARY_DIRS
- /usr/local/lib
- /usr/local/homebrew/lib
- /opt/local/lib
- /usr/lib)
-
- list(APPEND GLOG_CHECK_LIBRARY_SUFFIXES
- glog/lib
- glog/Lib
- Glog/lib
- Glog/Lib
- google-glog/lib
- google-glog/Lib)
-
- find_path(GLOG_INCLUDE_DIR
- NAMES glog/logging.h
- HINTS ${GLOG_INCLUDE_DIR_HINTS}
- PATHS ${GLOG_CHECK_INCLUDE_DIRS}
- PATH_SUFFIXES ${GLOG_CHECK_PATH_SUFFIXES})
- if (NOT GLOG_INCLUDE_DIR OR
- NOT EXISTS ${GLOG_INCLUDE_DIR})
- glog_report_not_found(
- "Could not find glog include directory, set GLOG_INCLUDE_DIR "
- "to directory containing glog/logging.h")
- endif (NOT GLOG_INCLUDE_DIR OR
- NOT EXISTS ${GLOG_INCLUDE_DIR})
- find_library(GLOG_LIBRARY NAMES glog
- HINTS ${GLOG_LIBRARY_DIR_HINTS}
- PATHS ${GLOG_CHECK_LIBRARY_DIRS}
- PATH_SUFFIXES ${GLOG_CHECK_LIBRARY_SUFFIXES})
- if (NOT GLOG_LIBRARY OR
- NOT EXISTS ${GLOG_LIBRARY})
- glog_report_not_found(
- "Could not find glog library, set GLOG_LIBRARY "
- "to full path to libglog.")
- endif (NOT GLOG_LIBRARY OR
- NOT EXISTS ${GLOG_LIBRARY})
-
-
- set(GLOG_FOUND TRUE)
-
-
-
-
-
- if (GLOG_INCLUDE_DIR AND
- NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h)
- glog_report_not_found(
- "Caller defined GLOG_INCLUDE_DIR:"
- " ${GLOG_INCLUDE_DIR} does not contain glog/logging.h header.")
- endif (GLOG_INCLUDE_DIR AND
- NOT EXISTS ${GLOG_INCLUDE_DIR}/glog/logging.h)
-
-
-
- string(TOLOWER "${GLOG_LIBRARY}" LOWERCASE_GLOG_LIBRARY)
- if (GLOG_LIBRARY AND
- NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*")
- glog_report_not_found(
- "Caller defined GLOG_LIBRARY: "
- "${GLOG_LIBRARY} does not match glog.")
- endif (GLOG_LIBRARY AND
- NOT "${LOWERCASE_GLOG_LIBRARY}" MATCHES ".*glog[^/]*")
-
- add_library(glog::glog INTERFACE IMPORTED)
- target_include_directories(glog::glog INTERFACE ${GLOG_INCLUDE_DIRS})
- target_link_libraries(glog::glog INTERFACE ${GLOG_LIBRARY})
- glog_reset_find_library_prefix()
- endif(NOT GLOG_FOUND)
- if (GLOG_FOUND)
- set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
- set(GLOG_LIBRARIES ${GLOG_LIBRARY})
- endif (GLOG_FOUND)
- if (FOUND_INSTALLED_GLOG_CMAKE_CONFIGURATION)
- set(GLOG_REQUIRED_VARIABLES GLOG_LIBRARIES)
- else()
- set(GLOG_REQUIRED_VARIABLES GLOG_INCLUDE_DIRS GLOG_LIBRARIES)
- endif()
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(Glog DEFAULT_MSG
- ${GLOG_REQUIRED_VARIABLES})
- if (GLOG_FOUND)
- mark_as_advanced(FORCE GLOG_INCLUDE_DIR
- GLOG_LIBRARY
- glog_DIR)
- endif (GLOG_FOUND)
|