3

My whole project uses

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

to place all runtime binaries in the bin directory.

However i need to place some dll's in a subdirectory named "scripts", i tried following code to set the variable for the specific target:

set_target_properties(my_script_dll PROPERTIES
    CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/scripts"
)

But it doesn't work, the dll's are still placed under bin.

Is there a way to set the output directory only for a specific target?

2 Answers 2

6

I solved it through using:

set_target_properties(my_script_dll PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin/Debug/scripts"
    RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin/Release/scripts"
    RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/bin/RelWithDebInfo/scripts"
    RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/bin/MinSizeRel/scripts"
)
Sign up to request clarification or add additional context in comments.

Comments

2

To add to previous answer, from my testing it seems this can be done in a shorter way:

set_target_properties(my_script_dll PROPERTIES
    RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>/scripts"
)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.