1

I am wondering if there is a CMake command line interface option, which does the same as --directory (-C) for GNU make?

What I want to do is to tell CMake to generate the build files in the source directory, not in CWD.


The quick and dirty way of doing this could be:

cd path/to/source && cmake . && make && make install

however, there must be a better way.

I was considering

cmake --build "path/to/source"

but that requires the build files to be present, and

cmake . -E chdir "path/to/source"

dumps the build files in CWD, just like:

cmake /path/to/source
usr1234567
  • 21,601
  • 16
  • 108
  • 128
Sigve Karolius
  • 1,356
  • 10
  • 26

1 Answers1

0

As CMake is a build system generator and it is not a replacement for make, your question does not make a lot of sense.

But the described behavior can be achieved. CMake has the options -H and -B to specify the source and binary directory, but they are undocumented. In your case this would be

cmake -Hpath/to/source -Bpath/to/source && cmake --build path/to/source
usr1234567
  • 21,601
  • 16
  • 108
  • 128
  • 1
    For those who somehow wander into this question, [this SO question](http://stackoverflow.com/questions/13712020/changing-cmake-files-standard-location) is essentially the same, but much more elegantly phrased. – Sigve Karolius Oct 21 '15 at 16:40