CmakeTools/README.md
2024-05-16 21:10:52 -04:00

1.9 KiB

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.