From f38cbfb29aa3633937dbb872cedcf63494214f6e Mon Sep 17 00:00:00 2001 From: Robert Middleton Date: Mon, 27 Nov 2023 15:11:26 -0500 Subject: [PATCH] Added some documentation on how to use with various buildsystems. #229 (#300) --- src/site/markdown/1-usage.md | 1 + src/site/markdown/buildsystems.md | 79 +++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 src/site/markdown/buildsystems.md diff --git a/src/site/markdown/1-usage.md b/src/site/markdown/1-usage.md index 76098f432..42b3d6480 100644 --- a/src/site/markdown/1-usage.md +++ b/src/site/markdown/1-usage.md @@ -38,3 +38,4 @@ See the following pages for usage information: * @subpage performance * @subpage conclusions * @subpage faq +* @subpage buildsystems diff --git a/src/site/markdown/buildsystems.md b/src/site/markdown/buildsystems.md new file mode 100644 index 000000000..13674bbac --- /dev/null +++ b/src/site/markdown/buildsystems.md @@ -0,0 +1,79 @@ +Usage with your build system {#buildsystems} +=== + + +[TOC] + +The following code snippets show how to use Log4cxx with various different buildsystems. + +Note that we are unable to provide support for all buildsystems that you may be using. + +CMake is fully supported for building, as well as any buildsystem that can use `pkgconfig` +in order to find packages. When using `pkgconfig`, the package name is `liblog4cxx`. + +# How do I use Log4cxx with CMake? {#use_with_cmake} + +Add the following to your CMakeLists.txt file: + +~~~ +find_package(log4cxx) + +... other buildsystem information here ... + +target_link_libraries( executable PRIVATE log4cxx ) +~~~ + +# How do I use Log4cxx with CMake and pkg-config? {#use_with_cmake_pkgconfig} + +Add the following to your CMakeLists.txt file: + +~~~ +find_package(PkgConfig) +pkg_check_modules(log4cxx REQUIRED liblog4cxx) + +... other buildsystem information here ... + +target_link_libraries( executable PRIVATE ${log4cxx_LIBRARIES} ) +target_include_directories( executable PRIVATE ${log4cxx_INCLUDE_DIRS} ) +~~~ + + +# How do I use Log4cxx with QMake? {#use_with_qmake} + +Add the following to your .pro file: + +~~~ +CONFIG += link_pkgconfig + +PKGCONFIG += liblog4cxx +~~~ + +# How do I use Log4cxx with plain Make? {#use_with_make} + +You probably don't want to do this - it is highly recommended to use a proper buildsystem. However, the following minimal Makefile will build and link an application: + +~~~ +CXXFLAGS += $(shell pkg-config --cflags liblog4cxx) +LDFLAGS += $(shell pkg-config --libs liblog4cxx) + +all: main.o + $(CXX) -o application main.o $(LDFLAGS) +~~~