Reputation: 809
I want to set the output executable using cmake. I've achieved this by using these:
SET( EXECUTABLE_OUTPUT_PATH ${dir}/bin )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bin )
But the problem is now everything is set inside /bin
including the binaries of all the libraries used in the project. I only want the executable created by my project to be inside /bin
. How can I achieve this?
Upvotes: 0
Views: 2127
Reputation: 82451
The cmake variable you set is just used to initialize the RUNTIME_OUTPUT_DIRECTORY
property of the target, unless it's this property is specified. This target property is what's actually determining the directory the binary for the will be created in. You can simply set this property for the target:
set_target_properties(my_target PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
Instead of setting CMAKE_RUNTIME_OUTPUT_DIRECTORY
.
Upvotes: 3