[CMake] Problems to get one target installed at several places
Brad King
brad.king at kitware.com
Fri Jan 14 07:51:17 EST 2005
Stefan Granqvist wrote:
> I am currently using CMake 2.0.3 on a Solaris platform. I would like to
> install the same target at several places in the installation tree, by
> using several INSTALL_TARGET commands, e.g.
> INSTALL_TARGET(/usr/bin myprogram)
> INSTALL_TARGET(/usr/local/bin myprogram)
>
> This does not work, only the last written command is executed by "make
> install".
[snip]
> Does anyone have any clues to get this to work nicely?
You can try using a post-install script to copy the executable from one
install destination to the other:
# CMakeLists.txt:
ADD_EXECUTABLE(foo foo.cxx)
INSTALL_TARGETS(/bin1 foo)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/post_install_foo.cmake.in
${PROJECT_BINARY_DIR}/post_install_foo.cmake
@ONLY IMMEDIATE)
SET_TARGET_PROPERTIES(foo PROPERTIES
POST_INSTALL_SCRIPT "${PROJECT_BINARY_DIR}/post_install_foo.cmake")
# post_install_foo.cmake.in:
EXEC_PROGRAM("@CMAKE_COMMAND@" ARGS -E copy
"$ENV{DESTDIR}@CMAKE_INSTALL_PREFIX@/bin1/foo"
"$ENV{DESTDIR}@CMAKE_INSTALL_PREFIX@/bin2/foo")
SET(CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_MANIFEST_FILES}
"@CMAKE_INSTALL_PREFIX@/bin2/foo")
The only part missing from this example is support for windows. It is
pretty easy to configure whether a .exe extension is included when
copying the file, but I'm guessing you don't need this backward
compatibility duplicate copy for windows because you said it came from
an old make system.
> Can the non-documented
> restriction of INSTALL_TARGET be removed/corrected in some future release?
Please submit this as a bug report here:
http://www.cmake.org/Bug
-Brad
More information about the CMake
mailing list