[cmake-developers] CMake aliasing system

Ruslan Baratov ruslan_baratov at yahoo.com
Sat Mar 12 08:04:35 EST 2016


Hi,

I guess it is a well known fact that cmake command is almost never 
executed alone and for non-trivial examples usually hold some extra 
arguments (home directory, build directory, verbosity level, toolchains, 
options, ...). Also I guess that such commands doesn't change from 
day-to-day development process and an obvious way to reduce typing is to 
create wrapper build scripts (.bat or .sh, I personally use a Python one).

I have next suggestion of how it can be unified: introduce ini-like file 
(say ${HOME}/.configs/cmake/alias) with alias sections with frequently 
used generators/arguments.

Example of such file:

   [default]
     var: CMAKE_VERBOSE_MAKEFILE=ON
     home: .
     build-dir: _builds/default

   [clean]
     cmd: cmake -E remove_directory _builds

   [vs-12]
     inherit: default
     generator: Visual Studio 12 2013
     build-dir: _builds/vs-12

   [iphone]
     inherit: default
     generator: Xcode
     build-dir: _builds/ios-9-2
     var: CMAKE_TOOLCHAIN_FILE=/.../ios-9-2.cmake

   [ipad]
     inherit: default
     generator: Xcode
     build-dir: _builds/ios-9-1
     var: CMAKE_TOOLCHAIN_FILE=/.../ios-9-1.cmake

Usage:

   > cmake -c clean ipad

effectively equivalent to:

   > cmake -E remove_directory _builds
   > cmake -H. -B_builds/ios-9-2 -DCMAKE_VERBOSE_MAKEFILE=ON -GXcode 
-DCMAKE_TOOLCHAIN_FILE=/.../ios-9-2.cmake

Name of the options may be:

   -c # classes (sectioins can be inherited)
   -a # alias
   -m # meta-targets

For now it's just a thought and I have no idea how it will work on 
practice so I can create a fork for experimenting. And if it will work 
fine for me I'm planning to add such feature to CMake upstream, so I'm 
ready to hear an appropriate implementation details.

Thoughts?

Ruslo



More information about the cmake-developers mailing list