]> granicus.if.org Git - graphviz/commitdiff
CMake: hoist common lines in dot symlinking/copying logic
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 10 Nov 2022 16:18:05 +0000 (08:18 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Fri, 11 Nov 2022 15:48:50 +0000 (07:48 -0800)
Fewer lines of code to accomplish the same thing.

cmd/dot/CMakeLists.txt

index 547ec0700f0a8caa3b307575b17e8efed4f69ac9..cab0cbff72d54d54a51f2e09013313f1cd84971e 100644 (file)
@@ -35,11 +35,11 @@ list(APPEND dot_aliases circo fdp neato osage patchwork sfdp twopi)
 # We use copying instead of symlinking for Cygwin to avoid
 # https://gitlab.com/graphviz/graphviz/-/issues/2123
 
-if(WIN32 OR CYGWIN)
-  # 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}")
+foreach(cmd_alias IN LISTS dot_aliases)
+  set(DOTCOPY
+      "${CMAKE_CURRENT_BINARY_DIR}/${cmd_alias}${CMAKE_EXECUTABLE_SUFFIX}")
+  if(WIN32 OR CYGWIN)
+    # Copy dot executable to each alias name then install copies to bindir
     add_custom_command(
       TARGET dot
       POST_BUILD
@@ -50,16 +50,13 @@ if(WIN32 OR CYGWIN)
       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}")
+  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
     add_custom_command(
       TARGET dot
       POST_BUILD
@@ -69,11 +66,11 @@ else()
       COMMENT "Linking dot as ${cmd_alias}"
     )
     install(
-      FILES ${DOTLINK}
+      FILES ${DOTCOPY}
       DESTINATION ${BINARY_INSTALL_DIR}
     )
-  endforeach()
-endif()
+  endif()
+endforeach()
 
 # Specify man pages to be installed
 if(GZIP)