Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use RENAME in INSTALL(TARGETS ...)

Tags:

cmake

I'm fairly new to CMake so please be gentle.

I have a two targets which both need to be called internal for further use on runtime. Now, when I call

set_target_properties(target1 PROPERTIES OUTPUT_NAME internal)
install(TARGETS target1 DESTINATION some/where/target1dir)

set_target_properties(target2 PROPERTIES OUTPUT_NAME internal)
install(TARGETS target2 DESTINATION some/where/target2dir)

one of the two targets will be overridden by the other one when invoking cmake, so when executing nmake in the build folder, the same file is copied to some/where/target1 and some/where/target2.

I considered using the RENAME option to change the temporary name of the built file to an arbitrary one, but this option is not allowed when using the TARGETS keyword.

Do you know how to solve this? Thank you!

like image 206
Roberto Avatar asked Oct 20 '22 09:10

Roberto


1 Answers

I worked around this by adding a CMake file to the source directory which renames the files, configuring that file with the target's output name and the rename name, then adding a target property POST_INSTALL_SCRIPT which holds the path to the configured cmake file.

Due to a lack of knowledge about variables available to determine certain directories (such as the location of the devel folder) there is still much stuff inside that is hardcoded and the whole workaround seems like overkill and is ugly, so, if YOU know a better strategy, PLEASE tell me :)

like image 155
Roberto Avatar answered Oct 23 '22 02:10

Roberto