From a8cade5ed7090c704aed53871fb664a0fe07af54 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Sat, 21 Apr 2018 20:07:09 +0200
Subject: [PATCH 1/3] Use GNUInstallDirs

---
 CMakeLists.txt | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index be57fe90c..1a54446fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -65,6 +65,8 @@ INCLUDE(BALLCompilerSpecific)
 # Determine BALL configuration
 INCLUDE(BALLConfiguration)
 
+INCLUDE(GNUInstallDirs)
+
 # We do not have a Component-based installer in MacOS
 IF(NOT APPLE)
 	INCLUDE(BALLComponents)
@@ -473,20 +475,20 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
 
 ## These variables are used in all install-targets
 IF (NOT APPLE)
-	SET(BALL_RUNTIME_INSTALL_DIRECTORY "bin")
-	SET(BALL_LIBRARY_INSTALL_DIRECTORY "lib")
-	SET(BALL_ARCHIVE_INSTALL_DIRECTORY "lib")
-	SET(BALL_HEADER_INSTALL_DIRECTORY   ".")
-	SET(BALL_DATA_INSTALL_DIRECTORY    "share/BALL")
-	SET(BALL_DOCUMENTATION_INSTALL_DIRECTORY    "share/BALL/doc")
-	SET(BALL_TOOLS_INSTALL_DIRECTORY   "bin/BALLTools")
+	SET(BALL_RUNTIME_INSTALL_DIRECTORY ${CMAKE_INSTALL_BINDIR})
+	SET(BALL_LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
+	SET(BALL_ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
+	SET(BALL_HEADER_INSTALL_DIRECTORY  ${CMAKE_INSTALL_INCLUDEDIR})
+	SET(BALL_DATA_INSTALL_DIRECTORY    ${CMAKE_INSTALL_DATAROOTDIR}/BALL)
+	SET(BALL_DOCUMENTATION_INSTALL_DIRECTORY    ${CMAKE_INSTALL_DOCDIR})
+	SET(BALL_TOOLS_INSTALL_DIRECTORY   ${CMAKE_INSTALL_BINDIR}/BALLTools)
 
 	IF(WIN32)
 		SET(BALL_PYTHON_INSTALL_DIRECTORY  "bin")
 		SET(BALL_PLUGIN_INSTALL_DIRECTORY  "bin")
 	ELSE()
-		SET(BALL_PYTHON_INSTALL_DIRECTORY  "lib")
-		SET(BALL_PLUGIN_INSTALL_DIRECTORY  "lib")
+		SET(BALL_PYTHON_INSTALL_DIRECTORY  ${CMAKE_INSTALL_LIBDIR})
+		SET(BALL_PLUGIN_INSTALL_DIRECTORY  ${CMAKE_INSTALL_LIBDIR})
 	ENDIF()
 ENDIF()
 
@@ -710,21 +712,21 @@ IF(NOT APPLE)
 	## care of data files and headers
 	IF (NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL ".")
 		### Install the data directories
-		INSTALL(DIRECTORY data DESTINATION "${BALL_DATA_INSTALL_DIRECTORY}" COMPONENT ${COMPONENT_LIBBALL})
+		INSTALL(DIRECTORY data/ DESTINATION "${BALL_DATA_INSTALL_DIRECTORY}" COMPONENT ${COMPONENT_LIBBALL})
 
 		### Install the includes
-		INSTALL(DIRECTORY include DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}" COMPONENT ${COMPONENT_LIBBALL_DEV})
+		INSTALL(DIRECTORY include/ DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}" COMPONENT ${COMPONENT_LIBBALL_DEV})
 	ENDIF()
 
 	## The configured files have to be copied in any case
 	INSTALL(FILES ${PROJECT_BINARY_DIR}/include/BALL/CONFIG/config.h
-		DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}/include/BALL/CONFIG"
+		DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}/BALL/CONFIG"
 		COMPONENT ${COMPONENT_LIBBALL_DEV}
 	)
 
 	INSTALL(FILES
 		${PROJECT_BINARY_DIR}/include/BALL/PYTHON/BALLPythonConfig.h
-		DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}/include/BALL/PYTHON"
+		DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}/BALL/PYTHON"
 		COMPONENT ${COMPONENT_LIBBALL_DEV}
 	)
 
@@ -866,7 +868,7 @@ EXPORT(PACKAGE BALL)
 # Generate CMake package configuration for BALL installation
 IF(NOT APPLE)
 	# Installation path for BALL CMake package configuration files
-	SET(BALL_CMAKE_EXPORT_PATH "lib/cmake/BALL" CACHE PATH "Path to the cmake package configuration files")
+	SET(BALL_CMAKE_EXPORT_PATH ${CMAKE_INSTALL_LIBDIR}/cmake/BALL CACHE PATH "Path to the cmake package configuration files")
 
 	LIST(REMOVE_ITEM BALL_INCLUDE_DIRS "${PROJECT_BINARY_DIR}/include")
 	LIST(REMOVE_ITEM BALL_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include")
-- 
2.17.0


From 17cbef40ad91cf051ca83b1ccf53dd2ccb22fc8d Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Sat, 21 Apr 2018 21:20:01 +0200
Subject: [PATCH 2/3] Drop superfluous cmake variables

---
 CMakeLists.txt                                | 34 +++++++------------
 cmake/BALLDoc.cmake                           |  6 ++--
 source/APPLICATIONS/BALLVIEW/CMakeLists.txt   |  4 +--
 source/EXTENSIONS/BALLAXY/CMakeLists.txt      |  2 +-
 source/EXTENSIONS/JUPYTER/CMakeLists.txt      |  2 +-
 source/EXTENSIONS/PRESENTABALL/CMakeLists.txt |  2 +-
 source/PYTHON/EXTENSIONS/CMakeLists.txt       | 12 +++----
 7 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1a54446fb..9b9f3513b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -475,14 +475,6 @@ SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
 
 ## These variables are used in all install-targets
 IF (NOT APPLE)
-	SET(BALL_RUNTIME_INSTALL_DIRECTORY ${CMAKE_INSTALL_BINDIR})
-	SET(BALL_LIBRARY_INSTALL_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
-	SET(BALL_ARCHIVE_INSTALL_DIRECTORY ${CMAKE_INSTALL_LIBDIR})
-	SET(BALL_HEADER_INSTALL_DIRECTORY  ${CMAKE_INSTALL_INCLUDEDIR})
-	SET(BALL_DATA_INSTALL_DIRECTORY    ${CMAKE_INSTALL_DATAROOTDIR}/BALL)
-	SET(BALL_DOCUMENTATION_INSTALL_DIRECTORY    ${CMAKE_INSTALL_DOCDIR})
-	SET(BALL_TOOLS_INSTALL_DIRECTORY   ${CMAKE_INSTALL_BINDIR}/BALLTools)
-
 	IF(WIN32)
 		SET(BALL_PYTHON_INSTALL_DIRECTORY  "bin")
 		SET(BALL_PLUGIN_INSTALL_DIRECTORY  "bin")
@@ -693,18 +685,18 @@ IF(NOT APPLE)
 	INSTALL(TARGETS BALL
 		EXPORT BALLExportGroup
 		COMPONENT "${COMPONENT_LIBBALL}"
-		RUNTIME DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
-		LIBRARY DESTINATION "${BALL_LIBRARY_INSTALL_DIRECTORY}"
-		ARCHIVE DESTINATION "${BALL_ARCHIVE_INSTALL_DIRECTORY}"
+		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 	)
 
 	IF(BALL_HAS_VIEW)
 		INSTALL(TARGETS VIEW
 			EXPORT BALLExportGroup
 			COMPONENT "${COMPONENT_LIBVIEW}"
-			RUNTIME DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
-			LIBRARY DESTINATION "${BALL_LIBRARY_INSTALL_DIRECTORY}"
-			ARCHIVE DESTINATION "${BALL_ARCHIVE_INSTALL_DIRECTORY}"
+			RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+			LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+			ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 		)
 	ENDIF()
 
@@ -712,21 +704,21 @@ IF(NOT APPLE)
 	## care of data files and headers
 	IF (NOT "${CMAKE_INSTALL_PREFIX}" STREQUAL ".")
 		### Install the data directories
-		INSTALL(DIRECTORY data/ DESTINATION "${BALL_DATA_INSTALL_DIRECTORY}" COMPONENT ${COMPONENT_LIBBALL})
+		INSTALL(DIRECTORY data/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/BALL COMPONENT ${COMPONENT_LIBBALL})
 
 		### Install the includes
-		INSTALL(DIRECTORY include/ DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}" COMPONENT ${COMPONENT_LIBBALL_DEV})
+		INSTALL(DIRECTORY include/ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" COMPONENT ${COMPONENT_LIBBALL_DEV})
 	ENDIF()
 
 	## The configured files have to be copied in any case
 	INSTALL(FILES ${PROJECT_BINARY_DIR}/include/BALL/CONFIG/config.h
-		DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}/BALL/CONFIG"
+		DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/BALL/CONFIG"
 		COMPONENT ${COMPONENT_LIBBALL_DEV}
 	)
 
 	INSTALL(FILES
 		${PROJECT_BINARY_DIR}/include/BALL/PYTHON/BALLPythonConfig.h
-		DESTINATION "${BALL_HEADER_INSTALL_DIRECTORY}/BALL/PYTHON"
+		DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/BALL/PYTHON"
 		COMPONENT ${COMPONENT_LIBBALL_DEV}
 	)
 
@@ -744,14 +736,14 @@ IF(NOT APPLE)
 		FOREACH(LIB ${BALL_DEP_OPT_DLLS})
 			STRING(TOLOWER "${LIB}" LOWER_LIB)
 			INSTALL(FILES "${LIB}"
-				DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
+				DESTINATION "${CMAKE_INSTALL_BINDIR}"
 				COMPONENT ${COMPONENT_LIBBALL})
 		ENDFOREACH()
 
 		IF(QT_DEPLOY_EXECUTABLE)
 			INSTALL(CODE
-				"EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${BALL_RUNTIME_INSTALL_DIRECTORY}/BALL.dll)
-				EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${BALL_RUNTIME_INSTALL_DIRECTORY}/VIEW.dll)"
+				"EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/BALL.dll)
+				EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/VIEW.dll)"
 				COMPONENT "${COMPONENT_LIBBALL}")
 		ENDIF()
 	ENDIF()
diff --git a/cmake/BALLDoc.cmake b/cmake/BALLDoc.cmake
index 061b9c95f..2d7c17466 100644
--- a/cmake/BALLDoc.cmake
+++ b/cmake/BALLDoc.cmake
@@ -20,7 +20,7 @@ ENDIF()
 
 IF(NOT APPLE)
 	INSTALL(DIRECTORY   "${PROJECT_SOURCE_DIR}/doc/examples/"
-		DESTINATION "${BALL_DOCUMENTATION_INSTALL_DIRECTORY}/EXAMPLES"
+		DESTINATION "${CMAKE_INSTALL_DOCDIR}/EXAMPLES"
 		COMPONENT   "${COMPONENT_DOCUMENTATION_EXAMPLES}")
 ENDIF()
 
@@ -53,7 +53,7 @@ IF (DOXYGEN_FOUND)
 
 	IF(NOT APPLE)
 		INSTALL(DIRECTORY   "${PROJECT_BINARY_DIR}/doc/html/"
-			DESTINATION "${BALL_DOCUMENTATION_INSTALL_DIRECTORY}/BALL"
+			DESTINATION "${CMAKE_INSTALL_DOCDIR}/BALL"
 			COMPONENT   "${COMPONENT_DOCUMENTATION_HTML}"
 		)
 	ENDIF()
@@ -107,7 +107,7 @@ IF (LATEX_COMPILER AND DVIPS_CONVERTER)
 
 	IF(NOT APPLE)
 		INSTALL(FILES   ${PROJECT_BINARY_DIR}/doc/tutorial.pdf
-			DESTINATION "${BALL_DOCUMENTATION_INSTALL_DIRECTORY}/TUTORIAL"
+			DESTINATION "${CMAKE_INSTALL_DOCDIR}/TUTORIAL"
 			COMPONENT   "${COMPONENT_DOCUMENTATION_PDF}"
 			OPTIONAL
 		)
diff --git a/source/APPLICATIONS/BALLVIEW/CMakeLists.txt b/source/APPLICATIONS/BALLVIEW/CMakeLists.txt
index b4b96c31c..5fd21ee68 100644
--- a/source/APPLICATIONS/BALLVIEW/CMakeLists.txt
+++ b/source/APPLICATIONS/BALLVIEW/CMakeLists.txt
@@ -59,13 +59,13 @@ IF(APPLE)
 ELSE()
 	INSTALL(TARGETS BALLView
 		COMPONENT "${COMPONENT_BALLVIEW}"
-		RUNTIME DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
+		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
 		BUNDLE DESTINATION "${BALL_BUNDLE_INSTALL_DIRECTORY}"
 	)
 
 	IF(WIN32)
 		IF(QT_DEPLOY_EXECUTABLE)
-			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${BALL_RUNTIME_INSTALL_DIRECTORY}/BALLView.exe)"
+			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/BALLView.exe)"
 				COMPONENT "${COMPONENT_BALLVIEW}")
 		ENDIF()
 	ENDIF()
diff --git a/source/EXTENSIONS/BALLAXY/CMakeLists.txt b/source/EXTENSIONS/BALLAXY/CMakeLists.txt
index 2fdfcbeed..1eed12c37 100644
--- a/source/EXTENSIONS/BALLAXY/CMakeLists.txt
+++ b/source/EXTENSIONS/BALLAXY/CMakeLists.txt
@@ -66,7 +66,7 @@ IF(NOT APPLE)
 
 	IF(WIN32)
 		IF(QT_DEPLOY_EXECUTABLE)
-			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${BALL_RUNTIME_INSTALL_DIRECTORY}/pluginBALLaxy.dll)"
+			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/pluginBALLaxy.dll)"
 				COMPONENT "Unspecified")
 		ENDIF()
 	ENDIF()
diff --git a/source/EXTENSIONS/JUPYTER/CMakeLists.txt b/source/EXTENSIONS/JUPYTER/CMakeLists.txt
index bb7e91921..24a459fbf 100644
--- a/source/EXTENSIONS/JUPYTER/CMakeLists.txt
+++ b/source/EXTENSIONS/JUPYTER/CMakeLists.txt
@@ -78,7 +78,7 @@ IF(NOT APPLE)
 
 	IF(WIN32)
 		IF(QT_DEPLOY_EXECUTABLE)
-			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${BALL_RUNTIME_INSTALL_DIRECTORY}/pluginJupyter.dll)"
+			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/pluginJupyter.dll)"
 				COMPONENT "Unspecified")
 		ENDIF()
 	ENDIF()
diff --git a/source/EXTENSIONS/PRESENTABALL/CMakeLists.txt b/source/EXTENSIONS/PRESENTABALL/CMakeLists.txt
index 8606f2f26..ad027fd03 100644
--- a/source/EXTENSIONS/PRESENTABALL/CMakeLists.txt
+++ b/source/EXTENSIONS/PRESENTABALL/CMakeLists.txt
@@ -66,7 +66,7 @@ IF(NOT APPLE)
 
 	IF(WIN32)
 		IF(QT_DEPLOY_EXECUTABLE)
-			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${BALL_RUNTIME_INSTALL_DIRECTORY}/pluginPresentaBALL.dll)"
+			INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${QT_DEPLOY_EXECUTABLE} \$\{CMAKE_INSTALL_PREFIX\}/${CMAKE_INSTALL_BINDIR}/pluginPresentaBALL.dll)"
 				COMPONENT "Unspecified")
 		ENDIF()
 	ENDIF()
diff --git a/source/PYTHON/EXTENSIONS/CMakeLists.txt b/source/PYTHON/EXTENSIONS/CMakeLists.txt
index 590e1de3a..374732519 100644
--- a/source/PYTHON/EXTENSIONS/CMakeLists.txt
+++ b/source/PYTHON/EXTENSIONS/CMakeLists.txt
@@ -49,15 +49,15 @@ IF(BALL_PYTHON_SUPPORT)
 	IF(NOT APPLE)
 		INSTALL(TARGETS BALLCoremodule
 			COMPONENT "${COMPONENT_PYTHON_BINDINGS_BALL}"
-			RUNTIME DESTINATION ${BALL_RUNTIME_INSTALL_DIRECTORY}
-			LIBRARY DESTINATION ${BALL_LIBRARY_INSTALL_DIRECTORY}
+			RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+			LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
 		)
 
 		IF(BALL_HAS_VIEW)
 			INSTALL(TARGETS VIEWmodule
 				COMPONENT "${COMPONENT_PYTHON_BINDINGS_VIEW}"
-				RUNTIME DESTINATION ${BALL_RUNTIME_INSTALL_DIRECTORY}
-				LIBRARY DESTINATION ${BALL_LIBRARY_INSTALL_DIRECTORY}
+				RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+				LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
 			)
 		ENDIF()
 
@@ -69,7 +69,7 @@ IF(BALL_PYTHON_SUPPORT)
 		IF (WIN32)
 			#		INSTALL(FILES ${PYTHON_EXECUTABLE}
 			#	COMPONENT "${COMPONENT_PYTHON_BINDINGS_BALL}"
-			#	DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
+			#	DESTINATION "${CMAKE_INSTALL_BINDIR}"
 			#)
 
 
@@ -78,7 +78,7 @@ IF(BALL_PYTHON_SUPPORT)
 
 			INSTALL(DIRECTORY "${PYTHON_SITE_PACKAGES_DIR}"
 				COMPONENT "${COMPONENT_PYTHON_BINDINGS_BALL}"
-				DESTINATION "${BALL_RUNTIME_INSTALL_DIRECTORY}"
+				DESTINATION "${CMAKE_INSTALL_BINDIR}"
 			)
 		ENDIF ()
 	ENDIF()
-- 
2.17.0


From 666ca19b00b14752e69c05600725724fb4f6d488 Mon Sep 17 00:00:00 2001
From: Andreas Sturmlechner <andreas.sturmlechner@gmail.com>
Date: Sat, 21 Apr 2018 22:02:14 +0200
Subject: [PATCH 3/3] Install html doc into "html" dir

---
 cmake/BALLDoc.cmake | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cmake/BALLDoc.cmake b/cmake/BALLDoc.cmake
index 2d7c17466..a070613c8 100644
--- a/cmake/BALLDoc.cmake
+++ b/cmake/BALLDoc.cmake
@@ -53,7 +53,7 @@ IF (DOXYGEN_FOUND)
 
 	IF(NOT APPLE)
 		INSTALL(DIRECTORY   "${PROJECT_BINARY_DIR}/doc/html/"
-			DESTINATION "${CMAKE_INSTALL_DOCDIR}/BALL"
+			DESTINATION "${CMAKE_INSTALL_DOCDIR}/html"
 			COMPONENT   "${COMPONENT_DOCUMENTATION_HTML}"
 		)
 	ENDIF()
-- 
2.17.0

