[CMake] VS2010 and OUTPUT_NAME problem

Brad King brad.king at kitware.com
Thu Jun 2 16:14:55 EDT 2011


On 05/28/2011 12:33 PM, Thomas Roß wrote:
> set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin CACHE PATH "" )
> to have all my executables in one place

This doesn't need to be in the cache.  You can just set() it in the top level.

> used set_target_properties( plugin PROPERTIES OUTPUT_NAME "plugins/plugin" )
> on the plugin target to get it created in the needed subdirectory.

The OUTPUT_NAME property does not support slashes.  It worked only by accident
in other generators.

The proper way to do this is to set the RUNTIME_OUTPUT_DIRECTORY on the target.
The documentation of the CMAKE_RUNTIME_OUTPUT_DIRECTORY:

  http://www.cmake.org/cmake/help/cmake-2-8-docs.html#variable:CMAKE_RUNTIME_OUTPUT_DIRECTORY

says just

  "used to initialize the RUNTIME_OUTPUT_DIRECTORY property on all the targets"

By setting the variable at the top you set the default used for all targets.
You can still change it for a specific target:

  set_property(TARGET plugin PROPERTY
    RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin/plugins")

-Brad


More information about the CMake mailing list