Anteru's blog
  • Consulting
  • Research
    • Assisted environment probe placement
    • Assisted texture assignment
    • Edge-Friend: Fast and Deterministic Catmull-Clark Subdivision Surfaces
    • Error Metrics for Smart Image Refinement
    • High-Quality Shadows for Streaming Terrain Rendering
    • Hybrid Sample-based Surface Rendering
    • Interactive rendering of Giga-Particle Fluid Simulations
    • Quantitative Analysis of Voxel Raytracing Acceleration Structures
    • Real-time Hybrid Hair Rendering
    • Real-Time Procedural Generation with GPU Work Graphs
    • Scalable rendering for very large meshes
    • Spatiotemporal Variance-Guided Filtering for Motion Blur
    • Subpixel Reconstruction Antialiasing
    • Tiled light trees
    • Towards Practical Meshlet Compression
  • About
  • Archive

CMake – A build tool that just works

September 22, 2008
  • Build systems
  • Linux
  • Programming
  • Windows
approximately 1 minutes to read

I’ve been using CMake 2.6 for quite some time now, and the more I do, the more I like it. Just a few days ago, I started with porting some project to Linux, and it took me literally a few minutes until I had the build going and started fixing portability problems in the code.

Basically, what CMake does (besides causing constant problems with my spelling checker who thinks it should be written Cmake) is to generate build files. It supports a variety of platforms and build tools. On Windows for example, you can generate build files for Visual Studio from version 6 to 9, including x64 versions, and nmake files (plus some other types). This is really helpful if you have for example an application that has to work on Win32 and Win64, as you don’t have to maintain two sets for the configuration. Moreover, you keep the option of porting it to Linux open.

And this is the killer-feature: It really works! Even if you started on Windows, your project will work (unless you used non-portable stuff) directly on Linux. No matter how complicated the dependencies are, whether you have pre- & post-build steps, if it is valid for CMake and works on one platform, it’ll also work on another. You can’t take this for granted: Previously, I’ve been using SCons, which usually required quite some work even to support several compilers on one platform, which was a major pain.

There are still some caveats you should keep in mind:

  • Linux is case sensitive, Windows not. Make sure you spell the filenames right, or you’ll get errors (you will get errors during #including later, too ;) ).
  • Beware that Linux comes usually with far more libraries than Windows, which will be found directly using the various Find* module scripts. I’ve been searching for Boost, and instead of finding my custom 1.36 install, it found (by default) the system installation which was 1.34.1.
  • Checking for the architecture on Linux requires to look at CMAKE_SYSTEM_PROCESSOR as there is no CMAKE_GCC_64. A simple IF("{CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64") should do the trick.
Previous post
Next post

Recent posts

  • Data formats: Why CSV and JSON aren't the best
    Posted on 2024-12-29
  • Replacing cron with systemd-timers
    Posted on 2024-04-21
  • Open Source Maintenance
    Posted on 2024-04-02
  • Angular, Caddy, Gunicorn and Django
    Posted on 2023-10-21
  • Effective meetings
    Posted on 2022-09-12
  • Older posts

Find me on the web

  • GitHub
  • GPU database
  • Projects

Follow me

Anteru NIV_Anteru
Contents © 2005-2025
Anteru
Imprint/Impressum
Privacy policy/Datenschutz
Made with Liara
Last updated February 03, 2019