Skip to content
/ cmake Public

Netlify's Common CMake Modules

License

Notifications You must be signed in to change notification settings

netlify/cmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This is the common set of CMake based modules used by all C++ projects at Netlify. For the most part, these include FindXXX.cmake files, but also support a few specific functions. Some of these will be removed in the future once Netlify migrates to using IXM for its projects, and this will instead work as a Project Blueprint for Netlify's internal projects.

Minimum Supported Platform

These are the only settings where these modules are used.

  • Ubuntu 20.04
  • Clang 10
  • C++2a
  • CMake 3.16

Any other compilers, operating systems, or languages are not guaranteed to be supported.

Roadmap

The following features are not yet (fully) implemented, but are currently planned

  • Better IXM Integration (This is reliant on IXM being released)
  • Custom Toolchain File (To ensure Clang, LLD, libc++, etc.)
  • Profile Guidance Code Generation
  • Sanitizer Support

Usage

This project is intended to be acquired via FetchContent. Thus, the following code should go at the top of every project's root CMakeLists.txt file.

cmake_minimum_required(VERSION 3.16)
include(FetchContent)
FetchContent_Declare(cmake GIT_REPOSITORY https://github.com/netlify/cmake GIT_TAG main)
FetchContent_MakeAvailable(cmake)

This will pull in the Netlify CMake Library, set several internal values, prepare various properties, etc.

If using additional CMake libraries via FetchContent, simply declare more of them before calling FetchContent_MakeAvailable.

Projects

Most projects will do the following

cmake_minimum_required(VERSION 3.16)
include(FetchContent)
FetchContent_Declare(cmake GIT_REPOSITORY https://github.com/netlify/cmake GIT_TAG main)
FetchContent_MakeAvailable(cmake)
set(CMAKE_PROJECT_INCLUDE ${NETLIFY_PROJECT_PRELUDE})
project(<project-name-here> LANGUAGES CXX)

This will attempt to set and find the most common flags and variables for our given target.

Behavior

Netlify's CMake modules perform the following operations when first included. This is done to ensure that we have a guaranteed behavior across all of our projects. However, this might disrupt others workflows. The changes these modules do are mentioned below:

  • CTest is included, but the CDash related targets are disabled.
  • CMAKE_EXPORT_COMPILE_COMMANDS is set to YES.
  • CMAKE_POLICY_DEFAULT_CMP0077 is set to NEW.
  • In-Source builds are disabled with a hard error
  • The Catch2 Unit Testing library is declared.
  • Color diagnostics are enabled by default.
  • -Og and -ggdb are enabled by default for Debug based builds.

About

Netlify's Common CMake Modules

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published