ozgur
ozgur

Reputation: 2719

How to prevent Cmake from creating Debug/Release folders under EXECUTABLE_OUTPUT_PATH?

I set EXECUTABLE_OUTPUT_PATH as ${CMAKE_BINARY_DIR}/bin but the executable is created in ${CMAKE_BINARY_DIR}/bin/Debug or ${CMAKE_BINARY_DIR}/bin/Release.

How can I make it put all output under ${CMAKE_BINARY_DIR}/bin without Debug/Release folders?

Upvotes: 6

Views: 5237

Answers (3)

DaHeiBuHei
DaHeiBuHei

Reputation: 9

CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE all letter must be capital,i wrote as CMAKE_RUNTIME_OUTPUT_DIRECTORY_Release and it didn't work.so stupid i am

Upvotes: 0

Tsyvarev
Tsyvarev

Reputation: 66288

Set variable CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG to the directory which will be used "as is" for Debug builds. Similarly, for Release builds variable CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE is used.

While you may set both these variables to the same value, note that executables created for release builds will overwrite ones for debug builds, which is not natural with CMake.

Upvotes: 5

Torbjörn
Torbjörn

Reputation: 5820

I assume you are using either Visual Studio or XCode. Thus, you might want to set RUNTIME_OUTPUT_DIRECTORY instead:

Output directory in which to build RUNTIME target files.

This property specifies the directory into which runtime target files should be built. The property value may use generator expressions. Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory unless a generator expression is used.

This property is initialized by the value of the variable CMAKE_RUNTIME_OUTPUT_DIRECTORY if it is set when a target is created.

See also the RUNTIME_OUTPUT_DIRECTORY_<CONFIG> target property.

Upvotes: 0

Related Questions