Giter Club home page Giter Club logo

cmakeall's Introduction

CMakeAll

Dependency management using CMake and its ExternalProject module.

license release build

Getting started

cmake_minimum_required(VERSION 2.8.7)
project(HelloWorld)

find_package(CMakeAll 1.2 REQUIRED)

cma_add_projects("/source/dir/ProjectA.cmake")

cma_add_projects(ProjectB ProjectC ProjectD
  PREFIX "${PROJECT_SOURCE_DIR}/"
  SUFFIX ".cmake")

cma_configure_projects()
cma_configure_launcher()
cma_print_projects()

where a simple project definition script for ProjectA may contain:

set(EP_REQUIRED_PROJECTS ProjectB)
set(EP_URL "https://github.com/organization/ProjectA.git")

cma_end_definition()

ExternalProject_Add(${EP_NAME}
  DEPENDS ${EP_REQUIRED_PROJECTS}
  GIT_REPOSITORY ${EP_URL}
  GIT_SHALLOW ON
  GIT_TAG "v1.0"
  SOURCE_DIR ${PROJECT_BINARY_DIR}/${EP_NAME}
  CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=Relase
  BINARY_DIR ${PROJECT_BINARY_DIR}/${EP_NAME}-build
  INSTALL_COMMAND "")

Variables listed below can be used to define a project, and should be set prior to calling cma_end_definition.

set(EP_NAME "${FILENAME}")    # project name
set(EP_REQUIRED_PROJECTS "")  # list of required projects
set(EP_REQUIRED_OPTIONS "")   # list of required options
set(EP_URL)                   # URL(s) of remote location to be verified
set(EP_PATCH "")              # patch file to apply

set(EP_OPTION_NAME "${DIRNAME}_${EP_NAME}")  # project CMake option
set(EP_OPTION_DEFAULT OFF)                   # default value of option
set(EP_OPTION_DEPENDENT OFF)                 # hide option until requirements are met
set(EP_OPTION_DESCRIPTION "")                # option description
set(EP_OPTION_ADVANCED OFF)                  # mark option as advanced

Each project may define its own environment variables using cma_envvar.

cma_envvar(PATH PREPEND @BINARY_DIR@/@LIBDIR@/@INTDIR@)

# variables that expand at build-time
set(INTDIR "@INTDIR@")
set(LIBDIR "@LIBDIR@")
set(SOURCE_DIR "@SOURCE_DIR@")
set(BINARY_DIR "@BINARY_DIR@")
set(INSTALL_DIR "@INSTALL_DIR@")

which are then used to configure a launcher script that may be used as:

cmake -P /binary/dir/HelloWorld.cmake

Obtaining

Option 1. Standard method where CMake will request the path to your local copy.

find_package(CMakeAll 1.2 REQUIRED)

Option 2. Using FindCMakeAll.cmake where the project is automatically cloned from GitHub. If version number is not specified main branch is cloned and updated with each configure.

list(APPEND CMAKE_MODULE_PATH "/path/to/FindCMakeAll.cmake")
find_package(CMakeAll 1.2 REQUIRED)

cmakeall's People

Contributors

auneri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cmakeall's Issues

Reconsider revert/patch project

Standard ExternalProject behavior is Download > Update > Patch.

  • ✗ patching is applied only once, conflicts with update.

RevertProject, when

  • source exists (after download), and
  • patch file is updated, or
  • update is required.

PatchProject, when

  • RevertProject step is out of date.
  • ✗ updating patched projects implies re-patching.

UpdateProject?

  • ✓ an update command that does trigger dependent steps if not needed.
  • ✓ should check for git/svn as well as tar/zip.

Avoid use of reserved words

Reserved words can be identified with the following commands:

cmake --help-command-list
cmake --help-variable-list
cmake --help-property-list

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.