Mike
Mike

Reputation: 137

How do I set the build path in cmake?

I am a total newb to cmake, I am kind of overwhelmed at the moment.

The library I am using creates a visual studio project file using cmake. I would like to edit the cmake file so that it changes the "Output Directory" of the visual studio project to "../../../build/$(Configuration)/". I have no idea how to do this though.

Upvotes: 4

Views: 5663

Answers (2)

Tigger
Tigger

Reputation: 63

I ran into the same problem and ended up using CMAKE_RUNTIME_OUTPUT_DIRECTORY to set it. For your case it would be: set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../../build)

Upvotes: 0

antonakos
antonakos

Reputation: 8361

Try adding these lines to your CMakeLists.txt file:

set(dir ${CMAKE_CURRENT_SOURCE_DIR}/../../build)
set(EXECUTABLE_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)
set(LIBRARY_OUTPUT_PATH ${dir} CACHE PATH "Build directory" FORCE)

Upvotes: 2

Related Questions