I am working on post build, INSTALL command. After I build my project, I build INSTALL project,which copies directories to User Specified location. I have that working fine using
install(TARGETS EXECTUABLE RUNTIME DESTINATION CMAKE_INSTALL_PREFIX/USERSPECIFIEDLOCATION).
I would like to change this to
install(TARGETS EXECTUABLE RUNTIME DESTINATION CMAKE_INSTALL_PREFIX/DEBUG or RELEASE).
So, if I build using debug in VS2012, it should copy executable to CMAKE_INSTALL_PREFIX/DEBUG instead of CMAKE_INSTALL_PREFIX/USERSPECIFIEDLOCATION.
Thanks in advance.
You'll find an answer to your question if you look closer to documentation:
The CONFIGURATIONS argument specifies a list of build configurations
for which the install rule applies (Debug, Release, etc.).
Example:
add_executable(boo boo.cpp)
install(
TARGETS
boo
CONFIGURATIONS
Debug
DESTINATION
bin/Debug
)
install(
TARGETS
boo
CONFIGURATIONS
Release
DESTINATION
bin/Release
)
DEBUG_POSTFIX
But I think that all you need is CONFIG_POSTFIX target property:
add_executable(bar bar.cpp)
add_library(baz baz.cpp)
set_target_properties(bar baz PROPERTIES DEBUG_POSTFIX d)
install(TARGETS bar DESTINATION bin)
install(TARGETS baz DESTINATION lib)
Building install
target with Release
configuration produce: bar.exe
and baz.lib
.
Building install
target with Debug
configuration produce: bard.exe
and bazd.lib
.
Note
Note that for libraries you can use CMAKE_DEBUG_POSTFIX (I don't know why, but CMAKE_DEBUG_POSTFIX
not applyed to executables):
set(CMAKE_DEBUG_POSTFIX d)
add_library(baz baz.cpp)
install(TARGETS baz DESTINATION lib)
Related
target_link_libraries. See debug
and optimized
.