From 3c56adba0dd66dc5e1266d943eac5da812f37cae Mon Sep 17 00:00:00 2001 From: Bob Apthorpe Date: Tue, 21 Jul 2020 12:54:20 -0500 Subject: [PATCH] Installs dot copies (WIN32) and symlinks --- cmd/dot/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/cmd/dot/CMakeLists.txt b/cmd/dot/CMakeLists.txt index 445dbebd1..00a4a283b 100644 --- a/cmd/dot/CMakeLists.txt +++ b/cmd/dot/CMakeLists.txt @@ -29,6 +29,46 @@ install( ARCHIVE DESTINATION ${LIBRARY_INSTALL_DIR} ) +# Aliases to the dot executable (not including '.exe' suffix) +list(APPEND dot_aliases circo fdp neato osage patchwork sfdp twopi) +if(WIN32) + # Copy dot executable to each alias name then install copies to bindir + foreach(cmd_alias IN LISTS dot_aliases) + set(dotcopy "${CMAKE_CURRENT_BINARY_DIR}/${cmd_alias}${CMAKE_EXECUTABLE_SUFFIX}") + add_custom_command( + TARGET dot + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy $ ${dotcopy} + COMMENT "Copying $ to ${dotcopy}" + ) + install( + PROGRAMS ${dotcopy} + DESTINATION ${BINARY_INSTALL_DIR} + ) + endforeach() +else() + # For not-WIN32, install symlinks from dot_aliases -> dot_executable in bindir. + # Note: This may be brittle. This builds a symlink from ./cmd_alias -> ./dot + # in ${CMAKE_CURRENT_BINARY_DIR}, then installs that symlink + # into ${BINARY_INSTALL_DIR}. This presumes ${CMAKE_CURRENT_BINARY_DIR}/dot + # is installed to ${BINARY_INSTALL_DIR}/dot. There is a (small?) risk of + # dangling symlinks + foreach(cmd_alias IN LISTS dot_aliases) + set(dotlink "${CMAKE_CURRENT_BINARY_DIR}/${cmd_alias}") + add_custom_command( + TARGET dot + POST_BUILD + COMMAND ${CMAKE_COMMAND} -E create_symlink $ ${cmd_alias} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Linking $ as ${cmd_alias}" + ) + install( + FILES ${dotlink} + DESTINATION ${BINARY_INSTALL_DIR} + ) + endforeach() +endif() + # Specify man pages to be installed install( FILES dot.1 osage.1 patchwork.1 -- 2.40.0