REVIEW - Modern CMake for C++, 2nd Edition - Effortlessly build cutting-edge C++ code and deliver high-quality solutions


Title:

Modern CMake for C++, 2nd Edition

Effortlessly build cutting-edge C++ code and deliver high-quality solutions

Author:

Rafał Świdziński

ISBN:

9781805121800

Publisher:

Packt (2024)

Pages:

504

Reviewer:

Paul Floyd

Reviewed:

March 2026

Rating:

★★★★☆


Recommended.

Reading this book on CMake, I had exactly the same problem that I had 15 years ago when I read a book on autotools. How to only review the book and not the tool (since CMake and autotools both have many detractors). So, I’ll start with my opinions on CMake. Building large complicated products is a messy business and the build tools are also complicated and messy. For the moment, CMake seems to be the least worst of a bad bunch.

I found the book quite comprehensive. There were a couple of things that I found difficult to understand just from reading a book – generator expressions and the parts on deployment rather than installation. I guess that I need to try out the example code and do some experiments.

Some sections of the book go into detail about various compiler and linker options. Whilst I can see that it is useful in general to explain these mechanisms, I did think that there was perhaps too much detail on the compiler options. One thing that I would liked to have seen was some sort of comparison between the CMake code and the generated Makefile, kind of like godbolt for CMake. I understand that the author didn’t want to make the book specific to any target make system and that it would have been infeasible to have godbolt-like output for GNU make, ninja, VS and XCode projects. So again it’s up to the reader to do that kind of exercise.

I thought that the chapter on using IDEs with CMake was a bit overly proselytising the use of IDEs. I don’t have enough experience to say whether this is good advice (i.e., do IDEs make using CMake significantly easier). I mostly use legacy projects, few of which use CMake and the ones that do are mostly old clunky CMake that IDEs can’t handle. I smiled at the comment that Hot Reload in VS 2022 is ‘very sophisticated’. It’s also quite old – I was using the same kind of feature on Sun Solaris back in the late 90s.

CMake isn’t the only tool covered. There are a couple of other tools in the CMake family. CTest, for testing code, is described using Catch2, Google Test and Valgrind (bonus points there!). There are also a few pages on using static checkers. There’s a chapter on CPack, the tool for installing and creating packages. The book ends (almost) with a wrap-up bringing together all the steps from previous chapters to describe the end-to-end process of creating a new CMake-based project.

The actual final chapter is about presets, which felt a bit like it should haven been an appendix. Perhaps it was a late addition?I felt that this book improved my understanding of CMake. I still find it incredibly difficult to get to grips with large CMake projects such as LLVM. Now I feel that I could use this book to start a new project or to move an existing smallish project to use CMake.

Website: https://www.packtpub.com/en-gb/product/modern-cmake-for-c-9781805121800

Code site: https://github.com/PacktPublishing/Modern-CMake-for-Cpp-2E






Your Privacy

By clicking "Accept Non-Essential Cookies" you agree ACCU can store non-essential cookies on your device and disclose information in accordance with our Privacy Policy and Cookie Policy.

Current Setting: Non-Essential Cookies REJECTED


By clicking "Include Third Party Content" you agree ACCU can forward your IP address to third-party sites (such as YouTube) to enhance the information presented on this site, and that third-party sites may store cookies on your device.

Current Setting: Third Party Content EXCLUDED



Settings can be changed at any time from the Cookie Policy page.