[CMake] adding a 'make altinstall' to cmake?

Rosen Diankov rosen.diankov at gmail.com
Wed May 4 04:04:17 EDT 2011


hi michael,

thanks for the tip, this makes a lot of sense. unfortunately, the
following does not work:

  add_custom_command(TARGET libopenrave POST_BUILD COMMAND
${CMAKE_COMMAND} -E create_symlink $<TARGET_FILE_NAME:libopenrave0.3>
$<TARGET_FILE_NAME:libopenrave> )

doing a grep on build.make, i see the following:

/usr/bin/cmake -E create_symlink $<TARGET_FILE_NAME:libopenrave0.3>
$<TARGET_FILE_NAME:libopenrave>

according to the documentation, the $<TARGET> stuff should have been
replaced right?

using cmake 2.8.0

thanks!
rosen,

2011/4/25 Michael Hertling <mhertling at online.de>:
> On 04/24/2011 08:35 AM, Rosen Diankov wrote:
>> Hi all,
>>
>> We would like to add a 'make altinstall' option similar to python's
>> altinstall so that it doesn't install symlinks that clobber the system
>> install's symlinks for our program.
>>
>> Basically, a normal install does:
>>
>> program0.3
>> program  -> program0.3        (using install(CODE))
>> libprogram.so.0.3
>> libprogram.so -> libprogram.so.0.3    (automatically done)
>>
>>
>> And altinstall should just do:
>>
>> program0.3
>> libprogram.so.0.3
>>
>> is there a way to do this?
>> thank you,
>> rosen,
>
> Look at the following CMakeLists.txt:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 2.8.4 FATAL_ERROR)
> PROJECT(ALTINSTALL C)
> SET(CMAKE_VERBOSE_MAKEFILE ON)
> FILE(WRITE ${CMAKE_BINARY_DIR}/f.c "void f(void){}\n")
> ADD_LIBRARY(f SHARED f.c)
> SET_TARGET_PROPERTIES(f PROPERTIES SOVERSION 1.0)
> INSTALL(TARGETS f RUNTIME DESTINATION lib LIBRARY DESTINATION lib)
> INSTALL(TARGETS f RUNTIME DESTINATION lib LIBRARY DESTINATION lib
>    NAMELINK_SKIP COMPONENT altinstall)
> FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n")
> ADD_EXECUTABLE(main main.c)
> SET_TARGET_PROPERTIES(main PROPERTIES OUTPUT_NAME "main1.0")
> ADD_CUSTOM_COMMAND(TARGET main POST_BUILD
>    COMMAND ${CMAKE_COMMAND} -E create_symlink
>    $<TARGET_FILE_NAME:main> ${CMAKE_BINARY_DIR}/main)
> INSTALL(TARGETS main RUNTIME DESTINATION bin)
> INSTALL(TARGETS main RUNTIME DESTINATION bin COMPONENT altinstall)
> INSTALL(FILES ${CMAKE_BINARY_DIR}/main DESTINATION bin)
> ADD_CUSTOM_TARGET(altinstall
>    ${CMAKE_COMMAND}
>    -DCOMPONENT=altinstall
>    -P ${CMAKE_BINARY_DIR}/cmake_install.cmake)
>
> The basic idea is to define an installation component "altinstall"
> along with an equally named custom target without ALL clause which
> installs the altinstall component in the known way, i.e. by running
> cmake_install.cmake with COMPONENT. For the library target, add two
> INSTALL() commands, one as usual and the other with a NAMELINK_SKIP
> and a COMPONENT clause. For the executable targets, I'd recommend to
> create the version symlink in the build tree via a POST_BUILD custom
> command. Use two INSTALL() commands here, too, and an additional one
> without COMPONENT to install the executables' symlinks when you are
> not performing the altinstall.
>
> 'hope that helps.
>
> Regards,
>
> Michael
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>


More information about the CMake mailing list