Quincy
Quincy

Reputation: 1939

how to use cmake to generate visual studio at specified build directory

I have cmake 2.8.2. and a project with directory like this: In the repository, I have bin directory to store built binary files. I can generate visual studio solution files in bin folder without any problem with cmake-gui. But I'd like to generate solution file using the command line version of cmake.

I tried cmake -G "Visual Studio 9 2008" .. in bin directory, but solution file is generated in the repository directory.

Upvotes: 1

Views: 3859

Answers (2)

André
André

Reputation: 19337

Under normal circumstances, simply running cmake -G"Visual Studio 9 2008" .. while in your bin directory should work.

However, if there is still a CMakeCache.txt file from earlier "in-source" build, this will not work. Is there a CMakeCache.txt in the .. directory? Is so, remove it and try again...

Upvotes: 1

David
David

Reputation: 9945

lets say you have

Repository/CMakeLists.txt
Repository/srcs...

and you create a bin directory in Repository:

cd Repository
mkdir bin
cd bin

then you can do what you want:

cmake -G "Visual Studio 9 2008" ..

and it will work.

Upvotes: 0

Related Questions