This repository contains CMake scripts I use in my projects to manage build options, preferences, properties, and utilities for a CMake-based project.
Go to file
2024-05-18 03:16:39 -04:00
BuildOptions.cmake Improve naming, update license in headers 2024-05-16 19:14:41 -04:00
BuildProperties.cmake Replace package_library_headers with simpler implementation 2024-05-18 03:16:39 -04:00
CPM.cmake Initial commit; standardizing these scripts from various projects 2024-05-16 18:56:21 -04:00
DefaultConfig.cmake Disable unit tests in default config if this repository is a submodule of another 2024-05-16 19:26:48 -04:00
LICENSE Initial commit; standardizing these scripts from various projects 2024-05-16 18:56:21 -04:00
README.md Fix Readme.md 2024-05-16 21:10:52 -04:00
Util.cmake Improve naming, update license in headers 2024-05-16 19:14:41 -04:00

CmakeTools

License CMake

Overview

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:

  • GitHub MIT

A convenience .cmake file with some default behavior is also included:

  • DefaultConfig.cmake
    • Contains some sane defaults to reduce repetitive typing

Getting Started

Prerequisites

  • CMake 3.26.0 or above. Might work with lesser verisons, but not tested.

Setup

  1. Create a project repository and a directory to contain these scripts. (e.g CMake)
  2.  $ git submodule add ${REPO_URL} CMake # You can use any directory name you wish
    

Usage

  1. Create your CMakeLists.txt

  2. 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)
    

License

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.