After running cmake/make for my own project, I noticed cmake puts object files into a directory named CMakeFiles/myproject.dir/
. How can I set a different build directory (e.g. bin/)
? I know of the variables CMAKE_BINARY_DIR
or CMAKE_CURRENT_BINARY_DIR
, but they are supposed to be read-only.
Asked
Active
Viewed 913 times
0

jbgs
- 2,795
- 2
- 21
- 28
-
http://stackoverflow.com/questions/6594796/how-do-i-make-cmake-output-into-a-bin-dir – Oct 26 '13 at 12:22
1 Answers
1
As you already note, you can't set CMAKE_BINARY_DIR
variable.
Depending on your purposes you can use:
add_executable(simple_bin ${SOURCES})
install(TARGETS simple_bin DESTINATION ${PROJECT_SOURCE_DIR}/bin)
add_executable(simple_bin ${SOURCES})
enable_testing()
add_test(test_name simple_bin --data-directory ${PROJECT_SOURCE_DIR}/bin)
-
This will put the executable file into `bin`directory. But what about the object files? They still are put into `CMakeFiles/myproject.dir` – jbgs Oct 26 '13 at 13:08
-
Well, I was interested in having my own directory layout... and out of curiosity. But it seems it is not very convenient and not so easy to achieve. Thanks! – jbgs Oct 26 '13 at 13:45