Type to search
Introduction to the
An Introduction to Modern CMake
Installing CMake
basics
Running CMake
Do's and Don'ts Minimum Version
What's new in CMake
Here's the first line of every CMakeLists.txt ,
Introduction to the Basics
which is the required name of the file CMake looks
Variables and the Cache
for:
Programming in CMake
cmake_minimum_required(VERSION 3.1)
Communicating with your code
How to Structure Your Project
Let's mention a bit of CMake syntax. The command
Running Other Programs
name cmake_minimum_required is case insensitive,
A Simple Example so the common practice is to use lower case. 1
The VERSION is a special keyword for this
Adding Features
function. And the value of the version follows the
C++11 and Beyond
keyword. Like everywhere in this book, just click on
Small but common needs the command name to see the official
documentation, and use the dropdown to switch
Utilities
documentation between CMake versions.
Useful modules
This line is special! 2 The version of CMake will
IDEs
also dictate the policies, which define behavior
Debugging changes. So, if you set minimum_required to
Including Projects VERSION 2.8 , you'll get the wrong linking behavior
on macOS, for example, even in the newest
Submodule
CMake versions. If you set it to 3.3 or less, you'll
DownloadProject get the wrong hidden symbols behaviour, etc. A list
Fetch (CMake 3.11) of policies and versions is available at policies.
Testing Starting in CMake 3.12, this supports a range, such
GoogleTest
as VERSION 3.1...3.15 ; this means you support
as low as 3.1 but have also tested it with the new
Catch
policy settings up to 3.15. This is much nicer on
Exporting and Installing users that need the better settings and due to a