This repository contains CMake scripts I use in my projects to manage build options, preferences, properties, and utilities for a CMake-based project.
The main scripts included are:
BuildOptions.cmake
Util.cmake
Additional third-party scripts included are:
A convenience .cmake file with some default behavior is also included:
DefaultConfig.cmake
- Contains some sane defaults to reduce repetitive typing
- CMake 3.26.0 or above. Might work with lesser verisons, but not tested.
- Create a project repository and a directory to contain these scripts. (e.g
CMake
) -
$ git submodule add ${REPO_URL} CMake # You can use any directory name you wish
-
Create your
CMakeLists.txt
-
Add this at the top:
# CMakeLists.txt cmake_minimum_required(VERSION 3.26) list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMake) include(Util) git_setup_submodules() include(BuildPreferences) iunclude(BuildOptions) prevent_in_source_build() disable_deprecated_features() ## or # include(DefaultConfig) project(MyProject)
The .cmake scripts in this repository are disstributed under the Unlicense - see the LICENSE file for details.
The included CPM.cmake module is © Lars Melchior and contributors, and is distributed under the MIT License - see the LICENSE file for details.