From 601f6af1fd07eb5427667d7ae840fe064f74b934 Mon Sep 17 00:00:00 2001 From: Ricky Zhang Date: Thu, 22 Dec 2016 11:30:18 -0500 Subject: [PATCH] Add CMake package support Signed-off-by: Ricky Zhang --- CMakeLists.txt | 2 +- CPackLists.txt | 2 ++ cmake/G3LOGConfig.cmake | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 cmake/G3LOGConfig.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 47eb352..707a081 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/CPackLists.txt b/CPackLists.txt index 41cae75..d5286d5 100644 --- a/CPackLists.txt +++ b/CPackLists.txt @@ -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") diff --git a/cmake/G3LOGConfig.cmake b/cmake/G3LOGConfig.cmake new file mode 100644 index 0000000..069627e --- /dev/null +++ b/cmake/G3LOGConfig.cmake @@ -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})