You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by ts...@apache.org on 2020/03/10 08:32:13 UTC
[logging-log4cxx] branch master updated: Fix support for
find_package(log4cxx) in consuming CMake projects (#19)
This is an automated email from the ASF dual-hosted git repository.
tschoening pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new 2410a3e Fix support for find_package(log4cxx) in consuming CMake projects (#19)
2410a3e is described below
commit 2410a3ec13bcb1b25b28af66e3b5203560f42faf
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Tue Mar 10 19:32:05 2020 +1100
Fix support for find_package(log4cxx) in consuming CMake projects (#19)
Fix support for find_package(log4cxx) in consuming CMake projects and add instructions for using log4cxx in a CMake build
Co-authored-by: Stephen Webb <st...@sabreautonomous.com.au>
---
CMakeLists.txt | 18 ++++++++++++++----
src/site/apt/building/cmake.apt | 15 +++++++++++++++
2 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51a9c5a..026d3b4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,7 @@ IF(WIN32 AND LOG4CXX_INSTALL_PDB)
ENDIF(WIN32 AND LOG4CXX_INSTALL_PDB)
if(UNIX)
+ # Support for pkg-config in consuming projects
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
@@ -54,13 +55,22 @@ if(UNIX)
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig)
endif(UNIX)
-
-# create export file which can be imported by other cmake projects
+# Support for find_package(log4cxx) in consuming CMake projects using
+# target_include_directories(myApplication PRIVATE $<TARGET_PROPERTY:log4cxx,INTERFACE_INCLUDE_DIRECTORIES>)
+# target_link_libraries( myApplication PRIVATE log4cxx)
install(EXPORT log4cxxTargets
- FILE log4cxx-targets.cmake
- NAMESPACE log4cxx::
+ FILE log4cxxConfig.cmake
DESTINATION share/cmake/log4cxx
)
+# Support for find_package(log4cxx 0.11) in consuming CMake projects
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/log4cxxConfigVersion.cmake"
+ VERSION ${PROJECT_VERSION}
+ COMPATIBILITY SameMinorVersion
+)
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/log4cxxConfigVersion.cmake"
+ DESTINATION share/cmake/log4cxx
+)
#
# Get the varaibles from the subdirectories
diff --git a/src/site/apt/building/cmake.apt b/src/site/apt/building/cmake.apt
index 2bcdb6f..b53374c 100644
--- a/src/site/apt/building/cmake.apt
+++ b/src/site/apt/building/cmake.apt
@@ -107,3 +107,18 @@ $ cd /usr/ports/devel/apr
$ make
$ make install
+----+
+
+* Using log4cxx in a CMake build
+
+ A log4cxxConfig.cmake and log4cxxConfigVersion.cmake is installed to allow use of find_package() in your CMakeLists.txt.
+
+ Below are example cmake commands that compile and link 'myApplication" with log4cxx.
+
++----+
+find_package(log4cxx 0.11)
+add_executable(myApplication myMain.cpp)
+target_include_directories(myApplication PRIVATE $<TARGET_PROPERTY:log4cxx,INTERFACE_INCLUDE_DIRECTORIES>)
+target_link_libraries( myApplication PRIVATE log4cxx)
++----+
+
+