How to set up a build system in C++, Python and Java

I don’t know why, but setting up the build system for a new software project and maintaining it seems to be something people are always afraid of. I’ve often heard people say “Eclipse does the job. It’s just additional work.” This usually leads to confusion and a lot of bulk and weird solutions several days later when the project starts to evolve, ultimately with much more “additional work”. Also in existing software project I have seen so many weird constructs effectively breaking the intended usage patterns and solutions of tools like CMake or setuptools, ending up with good software that is a nightmare to build and port to different platforms without insider knowledge. ...

May 15, 2013 · updated April 30, 2021 · 1 min

Relative RPath Settings with CMake

The run-time search path (rpath) defines paths to search for dynamic libraries when executing a program. It is a mechanism on Linux parallel to the LD_LIBRARY_PATH environment variable, which is another hint to find dynamic libraries. Usually, it is a good idea to make software which you built relocatable. This means that created binaries can be moved around and they still work after the location change. This includes the ability to still find the correct versions of dynamic libraries. One simple way to achieve this is by setting the rpath relative to the current location of the binary. In CMake this can be achieved like this: ...

February 16, 2012 · updated April 30, 2021 · 1 min

Using Dependency Tracking in Jenkins with CMake-based C++ Projects

If you are building multiple related software projects with a continuous integration server one important aspect is to be notified when changes in an upstream job break the build or tests for a downstream job. This involves knowing which exact build numbers of the upstream and the downstream job are involved. The Jenkins continuous integration server uses the notion of file fingerprints for this purpose. The upstream job is built by Jenkins and produces one or several so called artifacts, the results of the build process. The artifacts are archived by Jenkins and fingerprints (hash sums) for each artifact are created and stored along with the build number of the job. When the downstream job starts to build it downloads the (most recent) artifacts from the upstream job and uses them for its purposes, i.e. building and running the own source code. By comparing the fingerprints of the downloaded artifacts with the stored fingerprints Jenkins knows which version of each upstream job was involved in a build and can track which upstream build number broke the downstream job. Jenkins will only issue notifications if this fingerprinting mechanism is properly configured, triggering a build after another is not sufficient to receive these notifications. Moreover, the Blame Upstream Commiters plugin needs to be used and enabled for each downstream job or the global property hudson.upstreamCulprits (will this ever be renamed?) needs to be set. ...

July 31, 2011 · updated April 30, 2021 · 6 min

Gcov Coverage Reports in Jenkins

I am currently evaluating the applicability and limitations of the Jenkins continuous integration server for C++ development. Besides several limitations which are mainly caused by the complexity of C++, Jenkins provides a solid basis for continuous integration of C++ projects. One thing which I was not happy with so far was the missing integration of open-source coverage tools for Linux. Here, Gcov can be used to generate more or less precise coverage reports for projects compiled with GCC. Unfortunately, Gcov itself does not provide tools to export the results in any common or even nicely readable format. Until now, the only working solution I found was to use the Gcov front-end LCOV to generate a HTML report. This report is nice to read but it cannot be tracked by Jenkins with the drawback that no trend report for the code coverage can be generated. Nevertheless, I’ve wrapped the creation of such a HTML report in a CMake function and worked with it so far. ...

April 9, 2011 · updated April 30, 2021 · 2 min

Ignoring Warnings from System Headers

Compiling C and C++ code with the highest warning levels is a good practice and helps spotting potential errors. For GCC the flags -Wall -Wextra will generate a lot of useful warning messages about unused parameters etc. Unfortunately, this is not the common practice and often the own compiler settings concerning the warning level results in dozens of warnings from system headers on which the own code relies, making it impossible to spot warnings from your own code in the endless mass of console output. ...

August 20, 2010 · updated April 30, 2021 · 1 min

CMake: installing headers and preserving the directory structure

CMake doesn’t provide a dedicated way to install header files (except for mac). What I wanted to do was to install all headers of my project using the same directory structure as in the source tree. This isn’t as easy as it sounds. Assume you have a list of header files: SET(HS folder/test.h folder/other/test2.h) A simple call to INSTALL doesn’t preserve the folder structure: INSTALL(FILES ${HS} DESTINATION include) This results in all files being directly under $prefix/include. ...

May 31, 2010 · updated April 30, 2021 · 1 min

Out-of-Source Builds mit CMake

In der Java-Welt gibt es schon lange die sinnvolle Konvention kompilierte class-Dateien in einer anderen Verzeichnisstruktur abzulegen als den Quellcode. So eine eine Konvention hat viele Vorteile: Falls der Quellcode in ein Versionskontrollsystem eingecheckt wird (und das sollte er auf jeden Fall), müssen nicht umständliche Regeln zum Excluden der kompilierten Dateien geschrieben werden. Dateioperationen im Source-Tree (z. B. ein Aufruf von find oder grep) müssen nicht aufwendig um die kompilierten Dateien herumgelenkt werden Leider ist dies in der C++-Welt teilweise noch nicht ganz angekommen, deshalb hier ein kurzer Reminder, wie solche “Out-of-Source Builds” mit CMake gemacht werden können. ...

March 25, 2009 · updated April 30, 2021 · 2 min