





















































Hi ,
Welcome to a brand new issue of ProgrammingPro.
In today’s special edition of Expert Insight, we bring you an original article, "CMake, the one tool you’ll need for dependency management", written by Tom Hulton-Harrop, the author of Minimal CMake. The article discusses CMake's key features for dependency management focusing on FetchContent, ExternalProject, and Generators.
News Highlights: TypeScript transitions to a Go-based compiler for a 10x speed increase; OpenAI launches Responses API and Agents SDK to facilitate complex AI agent development; NVIDIA releases a new Rust-written "NOVA" driver for RTX 20 GPUs; and Veracode's report reveals greater security risks in third-party libraries compared to first-party code.
My top 5 picks from today’s learning resources:
But there’s more, so dive right in.
Stay Awesome!
Divya Anne Selvaraj
Editor-in-Chief
Legend:🎓 Tutorial/Course | 💼 Case Study | 💡 Insight/Analysis
return await
in JavaScript to ensure proper error handling within try..catch
blocks and to manage resource cleanup in try..finally
constructs effectively.By Tom Hulton-Harrop, author of Minimal CMake
CMake can be a tricky technology to explain, because on its own, it isn’t particularly useful. That isn’t really a problem though, because the entire point of CMake, is to connect bits of software together, be that source files on your computer, or libraries from other developers on the internet. CMake is the glue that binds these individual software components together. However, describing CMake as just glue, might actually be doing it a disservice. Making a project compatible with CMake is a bit more like attaching a universal adapter to your code to make connecting it with other software (be that as a library or application) possible, and relatively straightforward too.
In this article, we’ll learn about three key CMake features that make CMake an excellent choice for adding to your development tools. We will explore these using a simple application which simulates Conway’s Game of Life. The project is a desktop, windowed application that is fully cross platform, spanning Windows, macOS and Linux (thanks to the help of the excellent SDL 3.0 library). The complete code for the game-of-life-sdl3 project is available on GitHub. The project is an evolution of the application accompanying my book, Minimal CMake, upgraded from SDL2 to SDL3, with improved input handling and some other small changes.
We’ll only be focussing on the CMakeLists.txt files at the root of the repository and in the third-party folder (see <root>/CMakeLists.txt and <root>/third-party/CMakeLists.txt). Now let’s look at the three features CMake provides which make building software fast and simple:
FetchContent_Declare(
as
GIT_REPOSITORY https://github.com/pr0g/as.git
GIT_TAG a47a6deb8b5dbe408137aa4ce5cd556d26dc77c6)
FetchContent_MakeAvailable(as)
What the snippet above does is inform CMake to download and build this dependency automatically for us as part of our project. There are a wide array of different options for this, but the most common is just specifying a Git repository and a commit (or tag). All that’s then needed is to add the as dependency to our target_link_libraries command and that library will be available for use (this does rely on as itself being CMake compatible, the details of which are covered in “Chapter 3: Using FetchContent with External Dependencies” in Minimal CMake):
target_link_libraries(
${PROJECT_NAME} PRIVATE as ...)
ExternalProject_Add(
SDL3
GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
GIT_TAG release-3.2.4
GIT_SHALLOW TRUE
PREFIX ${PREFIX_DIR}/SDL3
BINARY_DIR ${PREFIX_DIR}/SDL3/build/${build_type_dir}
INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/install
CMAKE_ARGS ${build_type_arg} -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>)
ExternalProject_Add is incredibly useful for building larger dependencies that we may only want to build once, and then rely on for multiple projects. Having the build artifacts of these third-party dependencies kept separate can also be very convenient when wanting to delete and regenerate our own project’s build files, without then having to rebuild all of our third-party dependencies over again.
In the Game of Life project, to make working with ExternalProject_Add even easier, we’ve employed what’s often referred to as a super build. A super build is a way to combine the benefits of ExternalProject_Add with FetchContent, to allow us to build our project and all dependencies with one command (cmake --build <build-folder>). See the bottom of the CMakeLists.txt file in the third-party folder for how this is configured:
if(SUPERBUILD AND NOT PROJECT_IS_TOP_LEVEL)
set(THIRD_PARTY_BINARY_DIR
"${CMAKE_SOURCE_DIR}/build-third-party"
CACHE STRING "Third-party build folder")
if(NOT IS_ABSOLUTE ${THIRD_PARTY_BINARY_DIR})
set(THIRD_PARTY_BINARY_DIR "${CMAKE_SOURCE_DIR}/${THIRD_PARTY_BINARY_DIR}")
endif()
set(PREFIX_DIR ${THIRD_PARTY_BINARY_DIR})
else()
set(PREFIX_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
And the top of the root CMakeLists.txt file for where we check if a super build is enabled or not:
option(SUPERBUILD "Perform a superbuild (or not)" OFF)
if(SUPERBUILD)
add_subdirectory(third-party)
return()
endif()
The great thing is, we can easily disable the super build if we don’t want to use it or switch back and forward whenever is convenient. Providing this option is great for users to make building your project a more straightforward and less painful experience. The super build technique mentioned above is covered in more detail in “Chapter 8: Using Super Builds to Simplify Onboarding” in Minimal CMake.
To take advantage of this feature, when first configuring a project (before we actually build anything), we must specify what’s called a generator (using -G, or the system default), and use that to build our project (this is because CMake is technically a ‘build system generator’, and not a ‘build system’ itself; this distinction makes CMake very flexible). Below is an example showing how to specify various generators:
cmake -B build # use system default generator
cmake -B build -G “Ninja” # use Ninja generator
cmake -B build -G “VisualStudio172022” # use Visual Studio generator
And then to build, we simply run cmake –build build, no matter which generator we picked.
We’ve only scratched the surface of what’s possible with CMake, the ease with which you can integrate dependencies once you have a basic understanding of CMake cannot be overstated, and being able to build libraries others can use just as easily is incredibly satisfying. Do have a play around with the accompanying project, and if I’ve piqued your interest and you’d like to learn more, do give Minimal CMake a look. It’s packed full of practical examples, and explains all of this in much more detail, giving you everything you need to know to start building your own libraries and applications using CMake.
Author Bio:Tom Hulton-Harrop is a software developer with over 10 years of experience in game and engine development. Tom started his career in 2011 at Electronic Arts working on the Need for Speed series of racing games. In 2014, he joined Fireproof Games where he worked on The Room Three and later joined Amazon as part of the Lumberyard Game Engine team (later becoming Open 3D Engine). During this time, Tom became
interested in open source development and started sharing multiple hobby projects on GitHub. It was this experience that led Tom to CMake, where he slowly came to appreciate the power and simplicity of the tool. Tom now works at a start-up called Amutri, helping deliver 3D experiences to engineering, manufacturing, and lighting customers.
His book Minimal CMake, was published by Packt in January 2025.
That’s all for today.
We have an entire range of newsletters with focused content for tech pros. Subscribe to the ones you find the most usefulhere.
If your company is interested in reaching an audience of developers, software engineers, and tech decision makers, you may want toadvertise with us.
If you have any suggestions or feedback, or would like us to find you a learning resource on a particular subject, just respond to this email!