You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by sw...@apache.org on 2024/04/07 08:02:33 UTC
(logging-log4cxx) branch document_static_build created (now 726f2978)
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a change to branch document_static_build
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
at 726f2978 Improve instructions for building log4cxx
This branch includes the following new commits:
new 726f2978 Improve instructions for building log4cxx
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(logging-log4cxx) 01/01: Improve instructions for building log4cxx
Posted by sw...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch document_static_build
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit 726f29782efe9e1896d68632f88d9bef17ee7574
Author: Stephen Webb <sw...@gmail.com>
AuthorDate: Sun Apr 7 18:02:12 2024 +1000
Improve instructions for building log4cxx
---
src/site/markdown/development/build-cmake.md | 145 +++++++++++++++------------
1 file changed, 80 insertions(+), 65 deletions(-)
diff --git a/src/site/markdown/development/build-cmake.md b/src/site/markdown/development/build-cmake.md
index bbe54cee..1d496575 100644
--- a/src/site/markdown/development/build-cmake.md
+++ b/src/site/markdown/development/build-cmake.md
@@ -22,17 +22,54 @@ Building with CMake {#build-cmake}
-->
[TOC]
-## Quick start:
+# CMake options
- Building and testing Log4cxx on a Unix platform with packaged APR and APR-Util.
+| Option | Usage |
+|------------------------|-------|
+| -DLOG4CXX_WCHAR_T=no | Enable wchar_t API methods, choice of yes (default), no. |
+| -DLOG4CXX_UNICHAR=yes | Enable UniChar API methods, choice of yes, no (default). |
+| -DLOG4CXX_CFSTRING=yes | Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default). |
+| -DBUILD_TESTING=off | Do not build tests. Tests are built by default |
+| -DBUILD_SHARED_LIBS=off| Build Log4cxx as a static library. A dynamically linked Log4cxx library is built by default. Any compilation unit that includes a Log4cxx header must define LOG4CXX_STATIC. |
+| -DAPU_STATIC=yes | Link to the APR-Util static library. By default, the Log4cxx shared library is linked to the APR-Util shared library. If BUILD_SHARED_LIBS=off, the static APR-Util library is used. |
+| -DAPR_STATIC=yes | Link to the APR static library. By default, the Log4cxx shared library is linked to the APR shared library. If BUILD_SHARED_LIBS=off, the static APR library is always used. |
+|-DLOG4CXX_TEST_PROGRAM_PATH=path| An extra path to prepend to the PATH for test programs. Log4cxx requires zip, sed, and grep on the PATH in order for the tests to work properly. |
+| -DPREFER_BOOST=on | Prefer the Boost version of dependent libraries over standard library |
+| -DLOG4CXX_QT_SUPPORT=ON | Enable QString API and log4cxx::qt namespace methods, requires QtCore, choice of ON, OFF (default). |
+| -DLOG4CXX_EVENTS_AT_EXIT=ON | Prevent static data cleanup to allow event logging during application exit. |
+| -DLOG4CXX_FORMAT_NAMESPACE=std | Make the `LOG4CXX_[level]_FMT` macros use [std::format](https://en.cppreference.com/w/cpp/utility/format/format) by default. |
+
+# 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)
+~~~
+
+# Examples
+
+## Unix type systems
- Make sure cmake 3.13+, g++ and make are available, install or
- build apr 1.x, apr-util 1.x, gzip and zip.
+Make sure cmake (3.13+), g++, gzip, zip and make are available.
+On a Debian system these may be installed by:
+~~~
+$ sudo apt-get install build-essential cmake gzip zip
+~~~
-Linux example:
+1. Using the distro provided APR libraries
+and the cmake cursors UI to configure Log4cxx options.
~~~
-$ apt-get install build-essential libapr1-dev libaprutil1-dev gzip zip
-$ cd apache-Log4cxx-x.x.x
+$ apt-get install libapr1-dev libaprutil1-dev
+$ wget https://dlcdn.apache.org/logging/log4cxx/1.3.0/apache-log4cxx-1.3.0.tar.gz
+$ tar xf apache-log4cxx-1.3.0.tar.gz
+$ cd apache-log4cxx-1.3.0
$ mkdir build
$ cd build
$ ccmake ..
@@ -40,10 +77,41 @@ $ make
$ sudo make install
~~~
-Windows Example:
-Building and testing Log4cxx on a Microsoft Windows with APR, Expat and APR-Util built from source
-extracted into apr-1.7.4, libexpat(from github) and apr-util-1.6.3 in %HOMEPATH%/Libraries.
+2. Install libraries locally in $HOME/libraries and
+statically bind APR into the Log4cxx DSO.
+~~~
+$ wget https://archive.apache.org/dist/apr/apr-1.7.4.tar.bz2
+$ tar xf apr-1.7.4.tar.bz2
+$ cd apr-1.7.4
+$ CFLAGS=-fPIC ./configure --prefix=$HOME/libraries
+$ make install
+$ cd $HOME
+$ wget https://archive.apache.org/dist/apr/apr-util-1.6.3.bz2
+$ tar xf apr-util-1.6.3.bz2
+$ cd apr-util-1.6.3
+$ CFLAGS=-fPIC ./configure --with-apr=$HOME/libraries --prefix=$HOME/libraries
+$ make install
+$ cd $HOME
+$ wget https://dlcdn.apache.org/logging/log4cxx/1.3.0/apache-log4cxx-1.3.0.tar.gz
+$ tar xf apache-log4cxx-1.3.0.tar.gz
+$ cmake -S apache-log4cxx-1.3.0 -B build/log4cxx -DAPR_STATIC=yes -DAPU_STATIC=yes -DCMAKE_PREFIX_PATH=$HOME/libraries -DCMAKE_INSTALL_PREFIX=$HOME/Libraries -DCMAKE_BUILD_TYPE=Release
+$ cmake --build build/log4cxx --target install
+~~~
+
+## Windows
+1. The easiest way to get dependencies installed is to use vcpkg.
+Follow the directions at https://github.com/microsoft/vcpkg#quick-start-windows and then install
+the dependencies needed using `vcpkg install apr apr-util`.
+Command-line utilities(zip, grep, sed) are available in the Git for Windows distribution (C:/Program Files/Git/usr/bin/)
+or Msys2 can be downloaded from: https://www.msys2.org/ and by default will be installed under C:/msys2/bin.
+Unless you pass BUILD_TESTING=off, the location of command-line utilities must be provided
+to the Log4cxx cmake build in the LOG4CXX_TEST_PROGRAM_PATH cmake variable.
+
+2. Building from source in %HOMEPATH%/Libraries.
+Use your browser to download source for Expat from github, APR and APR-Util from https://archive.apache.org/dist/apr/
+and Log4cxx from https://dlcdn.apache.org/logging/log4cxx/1.3.0.
+Extract the source code into directories libexpat, apr-1.7.4, apr-util-1.6.3 and apache-log4cxx-1.3.0.
~~~
$ cd %HOMEPATH%/Libraries
$ cmake -S libexpat/expat -B buildtrees/expat -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed
@@ -53,43 +121,16 @@ $ cmake --build buildtrees/apr --target install --config Release
$ set CMAKE_PREFIX_PATH=%HOMEPATH%/Libraries/installed
$ cmake -S apr-util-1.6.3 -B buildtrees/apr-util -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed
$ cmake --build buildtrees/apr-util --target install --config Release
-$ cmake -S apache-Log4cxx-x.x.x -B buildtrees/Log4cxx -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed
-$ cmake --build buildtrees/Log4cxx --target install --config Release
+$ cmake -S apache-log4cxx-1.3.0 -B buildtrees/log4cxx -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed -DLOG4CXX_TEST_PROGRAM_PATH=C:/Program Files/Git/usr/bin
+$ cmake --build buildtrees/log4cxx --target install --config Release
~~~
-## CMake options
-
-| Option | Usage |
-|------------------------|-------|
-| -DLOG4CXX_WCHAR_T=no | Enable wchar_t API methods, choice of yes (default), no. |
-| -DLOG4CXX_UNICHAR=yes | Enable UniChar API methods, choice of yes, no (default). |
-| -DLOG4CXX_CFSTRING=yes | Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default). |
-| -DBUILD_TESTING=off | Do not build tests. Tests are built by default |
-| -DBUILD_SHARED_LIBS=off| Build Log4cxx as a static library. A dynamically linked Log4cxx library is built by default. Any compilation unit that includes a Log4cxx header must define LOG4CXX_STATIC. |
-| -DAPU_STATIC=yes | Link to the APR-Util static library. By default, the Log4cxx shared library is linked to the APR-Util shared library. If BUILD_SHARED_LIBS=off, the static APR-Util library is used. |
-| -DAPR_STATIC=yes | Link to the APR static library. By default, the Log4cxx shared library is linked to the APR shared library. If BUILD_SHARED_LIBS=off, the static APR library is always used. |
-|-DLOG4CXX_TEST_PROGRAM_PATH=path| An extra path to prepend to the PATH for test programs. Log4cxx requires zip, sed, and grep on the PATH in order for the tests to work properly. |
-| -DPREFER_BOOST=on | Prefer the Boost version of dependent libraries over standard library |
-| -DLOG4CXX_QT_SUPPORT=ON | Enable QString API and log4cxx::qt namespace methods, requires QtCore, choice of ON, OFF (default). |
-| -DLOG4CXX_EVENTS_AT_EXIT=ON | Prevent static data cleanup to allow event logging during application exit. |
-| -DLOG4CXX_FORMAT_NAMESPACE=std | Make the `LOG4CXX_[level]_FMT` macros use [std::format](https://en.cppreference.com/w/cpp/utility/format/format) by default. |
-
-# Platform specific notes:
-
## Mac OS/X:
APR and APR-Util are provided by the platform in Mac OS/X 10.5 and iODBC in 10.4.
cmake can be installed by typing "brew install cmake".
-## Debian:
-
-APR, APR-Util, openssl, gzip and zip may be installed by:
-
-~~~
-$ sudo apt-get install libssl-dev libapr1-dev libaprutil1-dev gzip zip
-~~~
-
CMake can be built from source by typing:
~~~
@@ -117,29 +158,3 @@ $ make
$ make install
~~~
-## Windows:
-
-The easiest way to get dependencies installed is to use vcpkg(for APR/expat), and msys2 for the command-line
-utilities(zip, grep, sed).
-
-Msys2 can be downloaded from: https://www.msys2.org/
-By default, this will be installed under C:\\msys2, so you can add that to the build PATH by setting
-LOG4CXX_TEST_PROGRAM_PATH=C:/msys64/usr/bin in your build settings.
-
-For vcpkg, follow the directions at https://github.com/microsoft/vcpkg#quick-start-windows and then install
-the dependencies needed using `vcpkg install apr apr-util`.
-
-# 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)
-~~~
-