[CMake] emulating cmake-gui behaviour with cmake commandline on windows

Johannes Schauer josch at debian.org
Fri Aug 7 05:08:08 EDT 2015


Hi,

I am trying to build the CMake project 3dtk with the following CMakeLists.txt:
https://sourceforge.net/p/slam6d/code/HEAD/tree/trunk/CMakeLists.txt

This works well on linux with ccmake and also on windows with cmake-gui.

Now I'm trying to let it work on windows with the cmake command line program to
automate the configuration. Unfortunately I'm running into a problem with cmake
on windows that I did not encounter with cmake-gui.

The CMakeLists.txt file at several occasions uses the add_subdirectory
directive but always without the second argument (the build_dir). This seems to
work fine for cmake-gui on windows and ccmake on linux. But with cmake on
windows I now get the following message for every add_subdirectory directive:

CMake Error at Z:/CMakeLists.txt:471 (add_subdirectory):
  add_subdirectory not given a binary directory but the given source
  directory "Z:/src/slam6d" is not a subdirectory of "Z:/". When specifying
  an out-of-tree source a binary directory must be explicitly specified.

This error message is also strange because clearly, "Z:/src/slam6d" is a
subdirectory of "Z:/".

I would like to know the command line option that I have to supply to cmake on
windows to get the same behaviour as with cmake-gui on windows.

In my case, the source is in Z:/ and in cmake-gui I specify
"Z:/lib64-msvc-12.0" as the value of "Where to build the binaries" and as
explained above this works completely well.

But after successfully configuring and generating the project in
"Z:/lib64-msvc-12.0" using the cmake-gui method, when I cd into
"Z:/lib64-msvc-12.0" and just run "cmake .." I get the error messages above.

Same happens when I create a new directory "Z:/cmaketest", cd into it and then
run "cmake ..", I again get the errors above.

So in summary, with or without an existing CMakeCache.txt, I'm running into the
error messages above on windows when using cmake (and not cmake-gui). So I
suspect that I'm missing an option to cmake to make it behave like cmake-gui.

I don't think my CMakeLists.txt is the culprit because that one works totally
fine on linux and also works well with cmake-gui.

What could the problem be?

Thanks!

cheers, josch
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: signature
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150807/035bc190/attachment.sig>


More information about the CMake mailing list