]> granicus.if.org Git - graphviz/commitdiff
CMake: use more standard, portable mechanism for setting install paths
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 25 Nov 2021 16:16:36 +0000 (08:16 -0800)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Thu, 3 Feb 2022 06:20:53 +0000 (17:20 +1100)
Fixes #1973.

Suggested-by: Satadru Pramanik
CHANGELOG.md
CMakeLists.txt
cmake/configure_plugins.cmake.in

index f85c5c005f7ddb50fe0a3eb1329298789d01d044..3b65e7da9930e9cb7aa79feb10f775d7982806c1 100644 (file)
@@ -78,6 +78,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - The tclpkg Makefile no longer suppresses `-fstack-clash-protection` nor
   other compiler options containing `-x`
 - Lefty is no longer enabled in the portable source tarball.
+- on Linux, the CMake build system uses the standard `GNUInstallDirs` to locate
+  target installation paths
 
 ### Fixed
 
@@ -93,6 +95,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
 - expr misinterprets `<<` and `>>` #2103
 - stdout and stderr are not flushed at exit on MinGW #2178
 - Gvedit on macOS now understands the `-?` help command line argument
+- CMAKE_LIBRARY_PATH is not honored #1973
 
 ## [2.50.0] – 2021-12-04
 
index 606391c333a02618f0d3b653fe257a9ac27b8782..8186859f8148b953ff2d2e516b59df548a4617c7 100644 (file)
@@ -63,12 +63,25 @@ endif()
 find_program(GZIP gzip)
 
 # ================== Convenient values for CMake configuration =================
-set(BINARY_INSTALL_DIR      bin)
-set(LIBRARY_INSTALL_DIR     lib)
+if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+  include(GNUInstallDirs)
+  set(BINARY_INSTALL_DIR  "${CMAKE_INSTALL_BINDIR}")
+  set(LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
+  set(HEADER_INSTALL_DIR  "${CMAKE_INSTALL_INCLUDEDIR}/graphviz")
+  set(MAN_INSTALL_DIR     "${CMAKE_INSTALL_MANDIR}")
+  set(libdir              "${CMAKE_INSTALL_FULL_LIBDIR}")
+  set(includedir          "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+else()
+  set(BINARY_INSTALL_DIR  bin)
+  set(LIBRARY_INSTALL_DIR lib)
+  set(HEADER_INSTALL_DIR  include/graphviz)
+  set(MAN_INSTALL_DIR     share/man)
+  set(libdir              "${CMAKE_INSTALL_PREFIX}/${LIBRARY_INSTALL_DIR}")
+  set(includedir          "${CMAKE_INSTALL_PREFIX}/include")
+endif()
+
 set(PLUGIN_INSTALL_DIR      ${LIBRARY_INSTALL_DIR}/graphviz)
-set(HEADER_INSTALL_DIR      include/graphviz)
-set(MAN_INSTALL_DIR         share/man)
-set(PKGCONFIG_DIR          lib/pkgconfig)
+set(PKGCONFIG_DIR           ${LIBRARY_INSTALL_DIR}/pkgconfig)
 # TODO: Find a way to check for groff and ps2pdf for manpage pdf generation
 # set(MAN_PDF_INSTALL_DIR share/graphviz/doc/pdf)
 set(TOP_SOURCE_DIR          "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -278,8 +291,6 @@ set(GVPLUGIN_VERSION "${GRAPHVIZ_PLUGIN_VERSION}")
 set(VERSION "${GRAPHVIZ_VERSION_STRING}")
 set(prefix "${CMAKE_INSTALL_PREFIX}")
 set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
-set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
-set(includedir "${CMAKE_INSTALL_PREFIX}/include")
 set(PACKAGE "graphviz")
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lib/cdt/libcdt.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/libcdt.pc @ONLY)
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lib/cgraph/libcgraph.pc.in ${CMAKE_CURRENT_SOURCE_DIR}/libcgraph.pc @ONLY)
index d4d41a17ba69031b4670e7afade9ccebc5902fb2..d0c8f0f95f163c77529175d617e91dee74c68e01 100644 (file)
@@ -30,9 +30,9 @@
 set(ROOT $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX})
 
 if(APPLE)
-  set(ENV{DYLD_LIBRARY_PATH} "${ROOT}/lib")
+  set(ENV{DYLD_LIBRARY_PATH} "${ROOT}/@LIBRARY_INSTALL_DIR@")
 elseif(UNIX)
-  set(ENV{LD_LIBRARY_PATH} "${ROOT}/lib")
+  set(ENV{LD_LIBRARY_PATH} "${ROOT}/@LIBRARY_INSTALL_DIR@")
 endif()
 
 execute_process(