Skip to content

Commit 8f0e1c1

Browse files
committed
launcher/CMake: Add symlink to bin on Linux
So it's available in $PATH Since CMAKE_INSTALL_BINDIR is overridden to CMAKE_INSTALL_LIBDIR on Linux, hardcode the bin directory as it's universal. We also have to do a weird dance of a temporary .link file in the build dir to get this to work correctly for distribution packaging purposes. See https://github.com/zeek/cmake/blob/master/InstallSymlink.cmake#L24
1 parent 38427fa commit 8f0e1c1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

code/Launcher/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,19 @@ function (create_launcher name type)
2222
set_target_properties(openmohaa_launcher_${name} PROPERTIES OUTPUT_NAME "launch_openmohaa_${name}${TARGET_BIN_SUFFIX}")
2323

2424
INSTALL(TARGETS openmohaa_launcher_${name} DESTINATION ${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR})
25+
26+
# Symlink launchers to $PATH
27+
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
28+
INSTALL(CODE "execute_process( \
29+
COMMAND ${CMAKE_COMMAND} -E create_symlink \
30+
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${BIN_INSTALL_SUBDIR}/launch_openmohaa_${name}${TARGET_BIN_SUFFIX} \
31+
${CMAKE_CURRENT_BINARY_DIR}/openmohaa_launcher_${name}.link \
32+
)")
33+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openmohaa_launcher_${name}.link DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
34+
RENAME launch_openmohaa_${name}${TARGET_BIN_SUFFIX})
35+
install(CODE "file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/openmohaa_launcher_${name}.link)")
36+
endif()
37+
2538
endif()
2639

2740
#add_executable(omohaaded_launcher_${name} ${LAUNCHER_SOURCES})

0 commit comments

Comments
 (0)