blob: 14ae98bbb0e3021d4b4cbeabe841d1381f2f45c3 [file] [log] [blame]
<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.6"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Apache Log4cxx: Building with CMake</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="customdoxygen.css" rel="stylesheet" type="text/css"/>
<!-- Matomo -->
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="https://analytics.apache.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '42']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Matomo Code -->
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">Apache Log4cxx
&#160;<span id="projectnumber">Version 1.2.0</span>
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.6 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
<div id="nav-tree">
<div id="nav-tree-contents">
<div id="nav-sync" class="sync"></div>
</div>
</div>
<div id="splitbar" style="-moz-user-select:none;"
class="ui-resizable-handle">
</div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('build-cmake.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>
<div><div class="header">
<div class="headertitle"><div class="title">Building with CMake </div></div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#autotoc_md14">Quick start:</a></li>
<li class="level1"><a href="#autotoc_md15">CMake options</a></li>
<li class="level1"><a href="#autotoc_md16">Platform specific notes:</a><ul><li class="level2"><a href="#autotoc_md17">Mac OS/X:</a></li>
<li class="level2"><a href="#autotoc_md18">Debian:</a></li>
<li class="level2"><a href="#autotoc_md19">FreeBSD:</a></li>
<li class="level2"><a href="#autotoc_md20">Windows:</a></li>
</ul>
</li>
<li class="level1"><a href="#autotoc_md21">Using Log4cxx in a CMake build</a></li>
</ul>
</div>
<div class="textblock"><p><a class="anchor" id="md_src_site_markdown_development_build_cmake"></a></p>
<h1><a class="anchor" id="autotoc_md14"></a>
Quick start:</h1>
<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>
<p>Linux example: </p><div class="fragment"><div class="line">$ apt-get install build-essential libapr1-dev libaprutil1-dev gzip zip</div>
<div class="line">$ cd apache-Log4cxx-x.x.x</div>
<div class="line">$ mkdir build</div>
<div class="line">$ cd build</div>
<div class="line">$ ccmake ..</div>
<div class="line">$ make</div>
<div class="line">$ sudo make install</div>
</div><!-- fragment --><p>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.</p>
<div class="fragment"><div class="line">$ cd %HOMEPATH%/Libraries</div>
<div class="line">$ cmake -S libexpat/expat -B buildtrees/expat -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed</div>
<div class="line">$ cmake --build buildtrees/expat --target install --config Release</div>
<div class="line">$ cmake -S apr-1.7.4 -B buildtrees/apr -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed</div>
<div class="line">$ cmake --build buildtrees/apr --target install --config Release</div>
<div class="line">$ set CMAKE_PREFIX_PATH=%HOMEPATH%/Libraries/installed</div>
<div class="line">$ cmake -S apr-util-1.6.3 -B buildtrees/apr-util -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed</div>
<div class="line">$ cmake --build buildtrees/apr-util --target install --config Release</div>
<div class="line">$ cmake -S apache-Log4cxx-x.x.x -B buildtrees/Log4cxx -DCMAKE_INSTALL_PREFIX=%HOMEPATH%/Libraries/installed</div>
<div class="line">$ cmake --build buildtrees/Log4cxx --target install --config Release</div>
</div><!-- fragment --><h1><a class="anchor" id="autotoc_md15"></a>
CMake options</h1>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Option </th><th class="markdownTableHeadNone">Usage </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">-DLOG4CXX_WCHAR_T=no </td><td class="markdownTableBodyNone">Enable wchar_t API methods, choice of yes (default), no. </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">-DLOG4CXX_UNICHAR=yes </td><td class="markdownTableBodyNone">Enable UniChar API methods, choice of yes, no (default). </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">-DLOG4CXX_CFSTRING=yes </td><td class="markdownTableBodyNone">Enable CFString API methods, requires Mac OS/X CoreFoundation, choice of yes, no (default). </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">-DBUILD_TESTING=off </td><td class="markdownTableBodyNone">Do not build tests. Tests are built by default </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">-DBUILD_SHARED_LIBS=off </td><td class="markdownTableBodyNone">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="markdownTableRowEven">
<td class="markdownTableBodyNone">-DAPU_STATIC=yes </td><td class="markdownTableBodyNone">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="markdownTableRowOdd">
<td class="markdownTableBodyNone">-DAPR_STATIC=yes </td><td class="markdownTableBodyNone">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>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">-DLOG4CXX_TEST_PROGRAM_PATH=path </td><td class="markdownTableBodyNone">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. </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">-DPREFER_BOOST=on </td><td class="markdownTableBodyNone">Prefer the Boost version of dependent libraries over standard library </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">-DLOG4CXX_QT_SUPPORT=ON </td><td class="markdownTableBodyNone">Enable QString API and <a class="el" href="namespacelog4cxx_1_1qt.html">log4cxx::qt</a> namespace methods, requires QtCore, choice of ON, OFF (default). </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">-DLOG4CXX_EVENTS_AT_EXIT=ON </td><td class="markdownTableBodyNone">Prevent static data cleanup to allow event logging during application exit. </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">-DLOG4CXX_FORMAT_NAMESPACE=std </td><td class="markdownTableBodyNone">Make the <code>LOG4CXX_[level]_FMT</code> macros use <a href="https://en.cppreference.com/w/cpp/utility/format/format">std::format</a> by default. </td></tr>
</table>
<h1><a class="anchor" id="autotoc_md16"></a>
Platform specific notes:</h1>
<h2><a class="anchor" id="autotoc_md17"></a>
Mac OS/X:</h2>
<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 "brew install cmake".</p>
<h2><a class="anchor" id="autotoc_md18"></a>
Debian:</h2>
<p>APR, APR-Util, openssl, gzip and zip may be installed by:</p>
<div class="fragment"><div class="line">$ sudo apt-get install libssl-dev libapr1-dev libaprutil1-dev gzip zip</div>
</div><!-- fragment --><p>CMake can be built from source by typing:</p>
<div class="fragment"><div class="line">$ wget https://github.com/Kitware/CMake/releases/download/v3.27.2/cmake-3.27.2.tar.gz</div>
<div class="line">$ tar xf cmake-3.27.2.tar.gz</div>
<div class="line">$ cd cmake-3.27.2</div>
<div class="line">$ ./bootstrap</div>
<div class="line">$ make</div>
<div class="line">$ sudo make install</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md19"></a>
FreeBSD:</h2>
<p>APR, APR-Util, gzip and zip may be installed from the ports collection by:</p>
<div class="fragment"><div class="line">$ cd /usr/ports/archivers/zip</div>
<div class="line">$ make</div>
<div class="line">$ make install</div>
<div class="line">$ cd /usr/ports/archivers/gzip</div>
<div class="line">$ make</div>
<div class="line">$ make install</div>
<div class="line">$ cd /usr/ports/devel/apr</div>
<div class="line">$ make</div>
<div class="line">$ make install</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md20"></a>
Windows:</h2>
<p>The easiest way to get dependencies installed is to use vcpkg(for APR/expat), and msys2 for the command-line utilities(zip, grep, sed).</p>
<p>Msys2 can be downloaded from: <a href="https://www.msys2.org/">https://www.msys2.org/</a> 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.</p>
<p>For vcpkg, follow the directions at <a href="https://github.com/microsoft/vcpkg#quick-start-windows">https://github.com/microsoft/vcpkg#quick-start-windows</a> and then install the dependencies needed using <code>vcpkg install apr apr-util</code>.</p>
<h1><a class="anchor" id="autotoc_md21"></a>
Using Log4cxx in a CMake build</h1>
<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 "myApplication" with Log4cxx.</p>
<div class="fragment"><div class="line">find_package(log4cxx 0.11)</div>
<div class="line">add_executable(myApplication myMain.cpp)</div>
<div class="line">target_include_directories(myApplication PRIVATE $&lt;TARGET_PROPERTY:log4cxx,INTERFACE_INCLUDE_DIRECTORIES&gt;)</div>
<div class="line">target_link_libraries( myApplication PRIVATE log4cxx)</div>
</div><!-- fragment --> </div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
<ul>
<li class="navelem"><a class="el" href="build.html">Build</a></li>
<li class="footer">Generated by
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="https://www.doxygen.nl/images/doxygen.png" alt="Doxygen"/></a> 1.9.6 on Thu Jan 25 2024 </li>
<li class="center">
Copyright &copy; 2003-2023 <a href="https://www.apache.org/">Apache Software Foundation</a>. All Rights Reserved. <a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a><br/>
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, and the Apache Logging project logo are trademarks of The Apache Software Foundation.<br/>
</li>
</ul>
</div>
</body>
</html>