0

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.

1

1 Answer 1

1

As you already note, you can't set CMAKE_BINARY_DIR variable.

Depending on your purposes you can use:

install

add_executable(simple_bin ${SOURCES}) install(TARGETS simple_bin DESTINATION ${PROJECT_SOURCE_DIR}/bin) 

add_test

add_executable(simple_bin ${SOURCES}) enable_testing() add_test(test_name simple_bin --data-directory ${PROJECT_SOURCE_DIR}/bin) 
Sign up to request clarification or add additional context in comments.

2 Comments

This will put the executable file into bindirectory. But what about the object files? They still are put into CMakeFiles/myproject.dir
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!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.