Coder Social home page Coder Social logo

andystanton / cool-makefile-for-cmake Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 6 KB

A Makefile that makes configuring and building CMake projects really simple.

License: MIT License

Makefile 82.57% Dockerfile 2.33% Shell 15.10%
cmake cmakelists makefile make cpp c cli build cool

cool-makefile-for-cmake's Introduction

Cool Makefile for CMake Projects

A Makefile that makes configuring and building CMake projects really simple.

Usage

Drop the Makefile into a directory containing a CMakeLists.txt, and run make to configure and build the project.

Alternatively, if you place the Makefile into a directory that does not contain a CMakeLists.txt and execute the init, configure, build, install, or run targets, you will be prompted for a project name and language (C or C++) for the creation of a skeleton CMake project.

Examples

Configure and build the project described by the CMakeLists.txt in the current directory, using Ninja (or Unix Makefiles if Ninja is unavailable) as the CMake generator with a build type of debug:

make

Configure, build, and run the project described by the CMakeLists.txt in the current directory, using Xcode as the CMake generator with a build type of release:

make generator=Xcode type=release run

Initialise a skeleton CMake project with an example C source file:

make project_name=foo project_lang=c init

Targets

  • make help: lists the supported targets.
  • make init: initialises a skeleton CMake project if there is no CMakeLists.txt in the current directory.
  • make configure: configures the build system for the selected generator.
  • make build: executes the build for the configured build system.
  • make install: executes the installation step (if any) for the configured build system.
  • make run: tries to run the project by calling the name of the last add_executable entry.
  • make clean: cleans the build directory for the active generator and build type.
  • make clean-all: cleans the build directories for all generators and build types.

Target dependencies

  • The default target is build.
  • run and install depend on build.
  • build depends on configure.
  • configure depends on init.

Variables

  • type: the CMake build type. Valid types are Release, Debug, RelWithDebInfo, and MinSizeRel. Default is Debug.
  • generator: the CMake generator to use. Supported generators are 'Ninja', 'Unix Makefiles', and 'Xcode'. Default is Ninja if the ninja executable is on the path, and Unix Makefiles if not.
  • build_path: allows overriding of the build path. Defaults to cmake-build-$type for 'Ninja' & 'Unix Makefiles' generators, and xcode-build for Xcode.

Variables that apply only to the init target

  • project_name: if supplied then the init target will not prompt for a project name.
  • project_lang: if supplied then the init target will not prompt for a project language. Valid languages are 'c' and 'cpp'.

Dependencies

  • Make
  • CMake
  • sh, egrep, sed, column, sort, head

Limitations

  • The Makefile is suitable for simple projects.
  • Not all CMake supported generators and platforms are supported by this Makefile.
  • Definitions of cool may vary.

Testing

The tests execute in a Debian Docker container and can be run as follows:

test/run-tests.sh

cool-makefile-for-cmake's People

Contributors

andystanton avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

lesssleep

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.