blob: bcf6fe3b0ec7f0528e7d3c7ef3e6b3d5e9dce1af [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!-- Generated by Apache Maven Doxia at 2020-08-22 -->
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>log4cxx - Building Apache log4cxx with CMake - Apache log4cxx</title>
<link rel="stylesheet" href="../css/bootstrap.min.css" type="text/css" />
<link rel="stylesheet" href="../css/site.css" type="text/css" />
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/prettify.min.js"></script>
<script type="text/javascript" src="../js/site.js"></script>
<meta name="Date-Revision-yyyymmdd" content="20200822" />
<meta http-equiv="Content-Language" content="en" />
</head>
<body class="composite">
<a href="https://logging.apache.org/">
<img class="logo-left" src="../images/logos/ls-logo.jpg" alt="Apache logging services logo" />
</a>
<img class="logo-right" src="../images/logos/logo.png" alt="Apache log4j logo" />
<div class="clear"></div>
<div class="navbar">
<div class="navbar-inner">
<div class="container-fluid">
<a class="brand" href="http://logging.apache.org/log4cxx">Apache log4cxx &#8482;</a>
<ul class="nav">
<li>
<a href="https://wiki.apache.org/logging" class="external" target="_blank" title="Logging Wiki">Logging Wiki</a>
</li>
<li>
<a href="https://www.apache.org/" class="external" target="_blank" title="Apache">Apache</a>
</li>
<li>
<a href="https://logging.apache.org/" class="external" target="_blank" title="Logging Services">Logging Services</a>
</li>
<li>
<a href="https://github.com/apache/logging-log4cxx" class="external" target="_blank" title="GitHub">GitHub</a>
</li>
</ul>
<div class="pull-right">
<span id="publishDate">Last Published: 2020-08-22</span>
<span class="divider">|</span> <span id="projectVersion">Version: 0.11.0</span>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<table class="layout-table">
<tr>
<td class="sidebar">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header"><i class="icon-home"></i>About</li>
<li class="none">
<a href="../index.html" title="What is log4cxx?">What is log4cxx?</a>
</li>
<li class="none">
<a href="../project-info.html" title="Project Information">Project Information</a>
</li>
<li class="none">
<a href="../project-reports.html" title="Generated Reports">Generated Reports</a>
</li>
</ul>
<ul class="nav nav-list">
<li class="nav-header"><i class="icon-book"></i>Usage</li>
<li class="none">
<a href="../usage.html" title="How to use log4cxx?">How to use log4cxx?</a>
</li>
<li class="none">
<a href="../apidocs/index.html" title="API Documentation">API Documentation</a>
</li>
<li class="none">
<a href="../faq.html" title="FAQ">FAQ</a>
</li>
</ul>
<ul class="nav nav-list">
<li class="nav-header"><i class="icon-cog"></i>Get</li>
<li class="none">
<a href="../download.html" title="Download">Download</a>
</li>
<li class="none">
<a href="../changes-report.html" title="Changes">Changes</a>
</li>
<li class="none">
<a href="../license.html" title="License">License</a>
</li>
</ul>
<ul class="nav nav-list">
<li class="nav-header"><i class="icon-pencil"></i>Community</li>
<li class="none">
<a href="../mail-lists.html" title="Mailing Lists">Mailing Lists</a>
</li>
<li class="none">
<a href="../community/issue-tracking.html" title="Issue Tracking">Issue Tracking</a>
</li>
<li class="none">
<a href="https://wiki.apache.org/logging-log4cxx" class="external" target="_blank" title="Wiki">Wiki</a>
</li>
</ul>
<ul class="nav nav-list">
<li class="nav-header"><i class="icon-pencil"></i>Development</li>
<li class="none">
<a href="../source-repository.html" title="Repository">Repository</a>
</li>
<li class="none">
<a href="../dependencies.html" title="Dependencies">Dependencies</a>
</li>
<li class="expanded">
<a href="../building/index.html" title="Building">Building</a>
<ul>
<li class="none">
<a href="../building/maven.html" title="Apache Maven 2">Apache Maven 2</a>
</li>
<li class="none">
<a href="../building/autotools.html" title="Autotools">Autotools</a>
</li>
<li class="none active">
<a href="../building/cmake.html" title="CMake">CMake</a>
</li>
<li class="none">
<a href="../building/vcpkg.html" title="Microsoft vcpkg">Microsoft vcpkg</a>
</li>
</ul>
</li>
</ul>
<ul class="nav nav-list">
<li class="nav-header"><i class="icon-info-sign"></i>Apache</li>
<li class="none">
<a href="https://www.apache.org" class="external" target="_blank" title="Home">Home</a>
</li>
<li class="none">
<a href="https://www.apache.org/foundation/sponsorship.html" class="external" target="_blank" title="Sponsorship">Sponsorship</a>
</li>
<li class="none">
<a href="https://www.apache.org/foundation/thanks.html" class="external" target="_blank" title="Thanks">Thanks</a>
</li>
<li class="none">
<a href="https://www.apachecon.com" class="external" target="_blank" title="Conferences">Conferences</a>
</li>
</ul>
</div>
<div id="poweredBy">
<a href="https://maven.apache.org/" title="Built by Maven" class="poweredBy">
<img class="poweredBy" alt="Built by Maven" src="../images/logos/maven-feather.png" />
</a>
</div>
</td>
<td class="content">
<!-- Licensed to the Apache Software Foundation (ASF) under one or more --><!-- contributor license agreements. See the NOTICE file distributed with --><!-- this work for additional information regarding copyright ownership. --><!-- The ASF licenses this file to You under the Apache License, Version 2.0 --><!-- (the "License"); you may not use this file except in compliance with --><!-- the License. You may obtain a copy of the License at --><!-- --><!-- http://www.apache.org/licenses/LICENSE-2.0 --><!-- --><!-- Unless required by applicable law or agreed to in writing, software --><!-- distributed under the License is distributed on an "AS IS" BASIS, --><!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. --><!-- See the License for the specific language governing permissions and --><!-- limitations under the License. --><div class="section">
<h2>Building Apache log4cxx with CMake<a name="Building_Apache_log4cxx_with_CMake"></a></h2>
<div class="section">
<h3>Quick start:<a name="Quick_start:"></a></h3>
<p>Building and testing log4cxx on a Unix platform with packaged APR and APR-Util.</p>
<p>Make sure cmake 3.13+, g++ and make are available, install or build apr 1.x, apr-util 1.x, gzip and zip.</p>
<div class="source">
<pre>$ apt-get install build-essential libapr1-dev libaprutil1-dev gzip zip
$ cd apache-log4cxx-x.x.x
$ mkdir build
$ cd build
$ ccmake ..
$ make
$ sudo make install</pre></div></div>
<div class="section">
<h3>ccmake options<a name="ccmake_options"></a></h3>
<table border="1" class="bodyTable">
<tr class="a">
<td align="left">-DLOG4CXX_WCHAR_T=no</td>
<td align="left">Enable wchar_t API methods, choice of yes (default), no.</td></tr>
<tr class="b">
<td align="left">-DLOG4CXX_UNICHAR=yes</td>
<td align="left">Enable UniChar API methods, choice of yes, no (default).</td></tr>
<tr class="a">
<td align="left">-DLOG4CXX_CFSTRING=yes</td>
<td align="left">Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default).</td></tr>
<tr class="b">
<td align="left">-DBUILD_TESTING=off</td>
<td align="left">Do not build tests. Tests are built by default</td></tr>
<tr class="a">
<td align="left">-DBUILD_SHARED_LIBS=off</td>
<td align="left">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.</td></tr>
<tr class="b">
<td align="left">-DAPU_STATIC=yes</td>
<td align="left">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.</td></tr>
<tr class="a">
<td align="left">-DAPR_STATIC=yes</td>
<td align="left">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.</td></tr></table>
<p>Building and testing log4cxx on a Microsoft Windows with APR, Expat and APR-Util built from source extracted into apr-1.7.0, libexpat(from github) and apr-util-1.6.1 in %HOMEPATH%\Libraries.</p>
<div class="source">
<pre>$ cd %HOMEPATH%\Libraries
$ cmake -S libexpat\expat -B buildtrees\expat -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed
$ cmake --build buildtrees\expat --target install --config Release
$ cmake -S apr-1.7.0 -B buildtrees\apr -DCMAKE_INSTALL_PREFIX=%HOMEPATH%\Libraries\installed
$ cmake --build buildtrees\apr --target install --config Release
$ set CMAKE_PREFIX_PATH=%HOMEPATH%\Libraries\installed
$ cmake -S apr-util-1.6.1 -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</pre></div></div>
<div class="section">
<h3>Platform specific notes:<a name="Platform_specific_notes:"></a></h3>
<div class="section">
<h4>Mac OS/X:<a name="Mac_OSX:"></a></h4>
<p>APR and APR-Util are provided by the platform in Mac OS/X 10.5 and iODBC in 10.4.</p>
<p>cmake can be installed by typing &quot;brew install cmake&quot;.</p></div>
<div class="section">
<h4>Debian:<a name="Debian:"></a></h4>
<p>APR, APR-Util, openssl, gzip and zip may be installed by:</p>
<div class="source">
<pre>$ sudo apt-get install libssl-dev libapr1-dev libaprutil1-dev gzip zip</pre></div>
<p>CMake can be built from source by typing:</p>
<div class="source">
<pre>$ wget https://github.com/Kitware/CMake/releases/download/v3.16.4/cmake-3.16.4.tar.gz
$ tar xf cmake-3.16.4.tar.gz
$ cd cmake-3.16.4
$ ./bootstrap
$ make
$ sudo make install</pre></div></div>
<div class="section">
<h4>FreeBSD:<a name="FreeBSD:"></a></h4>
<p>APR, APR-Util, gzip and zip may be installed from the ports collection by:</p>
<div class="source">
<pre>$ cd /usr/ports/archivers/zip
$ make
$ make install
$ cd /usr/ports/archivers/gzip
$ make
$ make install
$ cd /usr/ports/devel/apr
$ make
$ make install</pre></div></div></div>
<div class="section">
<h3>Using log4cxx in a CMake build<a name="Using_log4cxx_in_a_CMake_build"></a></h3>
<p>A log4cxxConfig.cmake and log4cxxConfigVersion.cmake is installed to allow use of find_package() in your CMakeLists.txt.</p>
<p>Below are example cmake commands that compile and link &quot;myApplication&quot; with log4cxx.</p>
<div class="source">
<pre>find_package(log4cxx 0.11)
add_executable(myApplication myMain.cpp)
target_include_directories(myApplication PRIVATE $&lt;TARGET_PROPERTY:log4cxx,INTERFACE_INCLUDE_DIRECTORIES&gt;)
target_link_libraries( myApplication PRIVATE log4cxx)</pre></div></div></div>
</td>
</tr>
</table>
</div>
<div class="footer">
<p>Copyright © 2003-2020 <a class="external" href="http://www.apache.org">Apache Software Foundation</a>. All Rights Reserved.</p>
<p>Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the Apache Logging project logo are trademarks of The Apache Software Foundation.</p>
<p>Site powered by <a class="external" href="https://getbootstrap.com/">Twitter Bootstrap</a>. Icons from <a class="external" href="https://glyphicons.com/">Glyphicons Free</a>.</p>
</div>
</body>
</html>