1

I tried multiple approaches:

  1. install(TARGETS tgt RUNTIME DESTINATION /usr/bin RENAME another_name) ignores RENAME without any warning. Documentation says no about RENAME for TARGETS.
  2. add_executable(zbus-publish ALIAS zbus-example-publisher) gives an error

    install TARGETS given target "zbus-publish" which is an alias.

  3. tried to install symlinks to installed targets

    install(CODE "execute_process(COMMAND ln -s zbus-example-publisher  ${DESTDIR}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/zbus-publish
                                  COMMAND ln -s zbus-example-subscriber ${DESTDIR}/${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/zbus-subscribe)
          message(==================================================)"
    

    But it expands DESTDIR to nothing.

I need DESTDIR because use make DESTDIR=xxxx to test my installation. It is very convenient. And also useful when cross-compiling.

CMake version 3.17.2

kyb
  • 7,233
  • 5
  • 52
  • 105
  • Why do you need to "rename" it on install? Why not have the desired name from the beginning? :) Please describe your case in more detail. – zaufi May 03 '20 at 09:23
  • And JFYI, `RENAME` works for `install(FILES...)` not for `install(TARGETS...)`. – zaufi May 03 '20 at 09:25
  • "But it expands DESTDIR to nothing." - So your **specific** problem is about handling `DESTDIR` in `install(CODE)` and not about symlinks in *general*, isn't it? – Tsyvarev May 03 '20 at 09:26
  • Another FYI (and a hint) `DESTDIR` is a GNU Make variable -- meaning *not CMake* :) And GNU Make pass it via **environment** to sub-processes. – zaufi May 03 '20 at 09:27
  • One more hint: `cmake -E create_symlink ...` is a **portable** way to make a symbolic link. – zaufi May 03 '20 at 09:30
  • @zaufi, I a writing install procedures for already existing bundle of SW, I am not legitimate to change targets names or any source code, but few installed executables are used under other names, so I need to keep target names as is and provide other names installed. This is my case. – kyb May 03 '20 at 10:11
  • @Tsyvarev, yes, my question is not about symlinks, I simply need renamed output file (executable or lib). – kyb May 03 '20 at 10:12
  • Thank you guys for attention to my question. Now it is resolved. – kyb May 03 '20 at 10:13
  • EDIT. not resolved but workarounded – kyb May 03 '20 at 10:53

1 Answers1

1

I found an answer here

You can change the Prefix, Output Name and Suffix using the set_target_properties() function and the PREFIX / OUTPUT_NAME / SUFFIX property in the following way:

Prefix:

set_target_properties(new_thing PROPERTIES PREFIX "")

Output Name:

set_target_properties(new_thing PROPERTIES OUTPUT_NAME "better_name")

Suffix:

set_target_properties(new_thing PROPERTIES SUFFIX ".so.1")

This is not exactly what I looked for. But works in special case.
I'd like to keep OUTPUT_NAMEs as is and create symlinks during install.

Community
  • 1
  • 1
kyb
  • 7,233
  • 5
  • 52
  • 105