Add CMake package support

Signed-off-by: Ricky Zhang <rickyzhang@gmail.com>
This commit is contained in:
Ricky Zhang 2016-12-22 11:30:18 -05:00
parent 6bf8afddfa
commit 601f6af1fd
No known key found for this signature in database
GPG Key ID: 681AFAEF6CDEDB4C
3 changed files with 30 additions and 1 deletions

View File

@ -112,7 +112,7 @@ endif()
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# ==========================================================================
# BETA : package manager for G3Log,. not yet reliable. Use at your own risk
# only tested on Ubuntu and CentOS

View File

@ -30,6 +30,8 @@
DESTINATION ${CMAKE_INSTALL_HEADERDIR}/g3log
COMPONENT headers)
INSTALL( FILES ${PROJECT_SOURCE_DIR}/cmake/G3LOGConfig.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/G3LOG)
SET(CPACK_COMPONENTS_ALL libraries headers)
SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "G3Log libraries")

27
cmake/G3LOGConfig.cmake Normal file
View File

@ -0,0 +1,27 @@
#.rst:
# FindG3log
# -------
#
# Find libg3logger, G3log is an asynchronous, "crash safe", logger that is easy to use with default logging sinks or you can add your own.
#
# Result variables
# ^^^^^^^^^^^^^^^^
#
# This module will set the following variables in your project:
#
# ``G3LOG_INCLUDE_DIRS``
# where to find g3log.hpp, etc.
# ``G3LOG_LIBRARIES``
# the libraries to link against to use libg3logger.
# that includes libg3logger library files.
# ``G3LOG_FOUND``
# If false, do not try to use G3LOG.
include(FindPackageHandleStandardArgs)
find_path(G3LOG_INCLUDE_DIR g3log/g3log.hpp)
find_library(G3LOG_LIBRARY
NAMES libg3logger g3logger)
find_package_handle_standard_args(G3LOG DEFAULT_MSG
G3LOG_INCLUDE_DIR G3LOG_LIBRARY)
mark_as_advanced(G3LOG_INCLUDE_DIR G3LOG_LIBRARY)
set(G3LOG_LIBRARIES ${G3LOG_LIBRARY})
set(G3LOG_INCLUDE_DIRS ${G3LOG_INCLUDE_DIR})