[CMake] LOCATION in VS
Brad King
brad.king at kitware.com
Thu Dec 11 12:21:00 EST 2008
Brad Aisa wrote:
> I am trying to use the LOCATION property of a library target in VS. VS
> is a bit complicated, because a single generate creates all 4 targets
> (Debug, Release, etc.) I want to add a custom target command. Here is
> what is in the file:
>
> _targ is a variable that contains a previous created target (ex. "temt")
>
>
> get_target_property(TARG_FILENAME ${_targ} LOCATION)
>
> add_custom_command(TARGET ${_targ} POST_BUILD
> COMMAND ${CMAKE_COMMAND} -E copy ${TARG_FILENAME}
> ${CMAKE_HOME_DIRECTORY}/bin)
>
> Now, in VS, for Debug, the target is correctly called:
>
> Linker:Output:
>
> C:\Users\baisa\Emergent\build_dbg\src\temt\lib\Debug\temt_dbg.dll
>
>
> But the Post Build Event:Command Line for Debug configuration contains:
>
> "C:\Program Files\CMake 2.6\bin\cmake.exe" -E copy
> C:/Users/baisa/Emergent/build_dbg/src/temt/lib/$(OutDir)/temt.dll
> C:/Users/baisa/Emergent/bin
>
> Notice that the _dbg is missing
The LOCATION property is an old feature intended for refering to
executables in custom commands (it is no longer needed because
add_custom_command recognizes target names as COMMANDs):
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:LOCATION
It does not work with per-configuration library names or suffixes.
If you want to place the library in a custom location, look at these
properties:
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:RUNTIME_OUTPUT_DIRECTORY
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:LIBRARY_OUTPUT_DIRECTORY
http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:ARCHIVE_OUTPUT_DIRECTORY
or use the install() command.
-Brad K
More information about the CMake
mailing list