问题
I've been having issues with changing the build directory via CLion. I've tried:
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "bin") but it does not seem to change and remains the same (/home/adil/.clion10/system/cmake/generated/c05c962b/c05c962b/Debug/Project).
I have also tried the workaround specified here, but that too does not seem to work.
Does anyone have a solution for this problem?
回答1:
You need to prefix your bin with the path to the current directory your project resides in. You can use ${CMAKE_CURRENT_SOURCE_DIR}
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
Be sure to add this before related add_executable directive(s) in your CMakeLists.txt file.
回答2:
Go to Settings -> CMake and specify relative or absolute pass where you would like your build files to be stored in 'Build output path' field. For instance ./bin will output build files in YourProject/bin/Debug/yourExeFile.exe
回答3:
The wiped's answer is correct, just I must be add that you have to put that set directive before the add_executable directive, and before the set directive where the source files are defined for the add_executable, if you don't do in this way, the output will be the same and no errors will launched.
回答4:
You can use set_target_properties :
set_target_properties( YOUR_PROJECT PROPERTIES RUNTIME_OUTPUT_DIRECTORY "YOUR_BUILD_DIRECTORY")
来源:https://stackoverflow.com/questions/26819712/clion-changing-the-default-build-directory