g3log/cmake/g3loggerConfig.cmake
myd7349 376c417ad1 Improve CMake module file (#312)
* Improve CMake module file
* Fix packaging on Win32
* appveyor: Test install and package target
* Travis-CI: Test install and package target
* Update documentation for working with CMake
* Simplify g3loggerConfig.cmake
* Add Doc Prerequisites section
2019-05-13 22:42:15 -06:00

55 lines
1.9 KiB
CMake

#.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.
#
# This defines the cmake import target "g3logger" you can use like this
#```
# target_link_libraries(YourTarget PUBLIC g3logger)
#```
# Variables and features
# ----------------------
# * ``G3LOG`` -- if this environment variable is set, it'll be used as a hint as to where the g3logger files are.
# * ``G3LOG_INCLUDE_DIRS`` -- raw cmake variable with include path
# * ``G3LOG_LIBRARIES`` -- raw cmake variable with library link line
# * ``G3LOG_FOUND`` -- check if the lib was found without using the newer ``if(TARGET g3logger)...``
include(FindPackageHandleStandardArgs)
include(SelectLibraryConfigurations)
@PACKAGE_INIT@
find_package(Threads REQUIRED)
if (NOT TARGET g3logger)
include("${CMAKE_CURRENT_LIST_DIR}/g3loggerTargets.cmake")
get_target_property(G3LOG_INCLUDE_DIR g3logger INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(G3LOG_LIBRARY_DEBUG g3logger IMPORTED_IMPLIB_DEBUG)
if (G3LOG_LIBRARY_DEBUG MATCHES ".*-NOTFOUND")
get_target_property(G3LOG_LIBRARY_DEBUG g3logger IMPORTED_LOCATION_DEBUG)
endif ()
get_target_property(G3LOG_LIBRARY_RELEASE g3logger IMPORTED_IMPLIB_RELEASE)
if (G3LOG_LIBRARY_RELEASE MATCHES ".*-NOTFOUND")
get_target_property(G3LOG_LIBRARY_RELEASE g3logger IMPORTED_LOCATION_RELEASE)
endif ()
select_library_configurations(G3LOG)
if (G3LOG_LIBRARY)
list(APPEND G3LOG_LIBRARY Threads::Threads)
if (WIN32)
list(APPEND G3LOG_LIBRARY DbgHelp.lib)
endif ()
endif ()
endif ()
find_package_handle_standard_args(G3LOG
REQUIRED_VARS G3LOG_INCLUDE_DIR G3LOG_LIBRARY)
mark_as_advanced(G3LOG_INCLUDE_DIR G3LOG_LIBRARY)
set(G3LOG_INCLUDE_DIRS ${G3LOG_INCLUDE_DIR})
set(G3LOG_LIBRARIES ${G3LOG_LIBRARY})