From fbdfac84763ce525e7d243eefbb23c013db93e32 Mon Sep 17 00:00:00 2001
From: Julian Ospald <hasufell@posteo.de>
Date: Tue, 24 May 2016 18:06:54 +0200
Subject: [PATCH] Use GNUInstallDirs

This will probably not make it upstream since they try to
be windows compatible.
---
 CMake/ConfigureBuild.cmake                     |  2 +-
 CMake/Utils/MyGUIConfigTargets.cmake           | 40 +++++++++++++-------------
 CMakeLists.txt                                 |  1 +
 MyGUIEngine/CMakeLists.txt                     |  2 +-
 Platforms/OpenGL/OpenGLPlatform/CMakeLists.txt |  2 +-
 5 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/CMake/ConfigureBuild.cmake b/CMake/ConfigureBuild.cmake
index 9c6aad9..b655848 100644
--- a/CMake/ConfigureBuild.cmake
+++ b/CMake/ConfigureBuild.cmake
@@ -47,7 +47,7 @@ if (UNIX)
   else ()
     configure_file(${MYGUI_TEMPLATES_DIR}/MYGUI.pc.in ${MYGUI_BINARY_DIR}/pkgconfig/MYGUI${MYGUI_LIB_SUFFIX}.pc @ONLY)
   endif ()
-  install(FILES ${MYGUI_BINARY_DIR}/pkgconfig/MYGUI${MYGUI_LIB_SUFFIX}.pc DESTINATION lib/pkgconfig)
+  install(FILES ${MYGUI_BINARY_DIR}/pkgconfig/MYGUI${MYGUI_LIB_SUFFIX}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 
   # configure additional packages
   
diff --git a/CMake/Utils/MyGUIConfigTargets.cmake b/CMake/Utils/MyGUIConfigTargets.cmake
index d48d2a3..61b80a5 100644
--- a/CMake/Utils/MyGUIConfigTargets.cmake
+++ b/CMake/Utils/MyGUIConfigTargets.cmake
@@ -60,27 +60,27 @@ endfunction(mygui_create_vcproj_userfile)
 # install targets according to current build type
 function(mygui_install_target TARGETNAME SUFFIX)
 	install(TARGETS ${TARGETNAME}
-		RUNTIME DESTINATION "bin${MYGUI_RELEASE_PATH}" CONFIGURATIONS Release None ""
-		LIBRARY DESTINATION "lib${MYGUI_LIB_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None ""
-		ARCHIVE DESTINATION "lib${MYGUI_LIB_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None ""
+		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}${MYGUI_RELEASE_PATH}" CONFIGURATIONS Release None ""
+		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None ""
+		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_RELEASE_PATH}${SUFFIX}" CONFIGURATIONS Release None ""
 		FRAMEWORK DESTINATION "${MYGUI_FRAMEWORK_PATH}" CONFIGURATIONS Release None ""
 	)
 	install(TARGETS ${TARGETNAME}
-		RUNTIME DESTINATION "bin${MYGUI_RELWDBG_PATH}" CONFIGURATIONS RelWithDebInfo
-		LIBRARY DESTINATION "lib${MYGUI_LIB_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo
-		ARCHIVE DESTINATION "lib${MYGUI_LIB_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo
+		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}${MYGUI_RELWDBG_PATH}" CONFIGURATIONS RelWithDebInfo
+		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo
+		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_RELWDBG_PATH}${SUFFIX}" CONFIGURATIONS RelWithDebInfo
 		FRAMEWORK DESTINATION "${MYGUI_FRAMEWORK_PATH}" CONFIGURATIONS RelWithDebInfo
 	)
 	install(TARGETS ${TARGETNAME}
-		RUNTIME DESTINATION "bin${MYGUI_MINSIZE_PATH}" CONFIGURATIONS MinSizeRel
-		LIBRARY DESTINATION "lib${MYGUI_LIB_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel
-		ARCHIVE DESTINATION "lib${MYGUI_LIB_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel
+		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}${MYGUI_MINSIZE_PATH}" CONFIGURATIONS MinSizeRel
+		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel
+		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_MINSIZE_PATH}${SUFFIX}" CONFIGURATIONS MinSizeRel
 		FRAMEWORK DESTINATION "${MYGUI_FRAMEWORK_PATH}" CONFIGURATIONS MinSizeRel
 	)
 	install(TARGETS ${TARGETNAME}
-		RUNTIME DESTINATION "bin${MYGUI_DEBUG_PATH}" CONFIGURATIONS Debug
-		LIBRARY DESTINATION "lib${MYGUI_LIB_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug
-		ARCHIVE DESTINATION "lib${MYGUI_LIB_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug
+		RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}${MYGUI_DEBUG_PATH}" CONFIGURATIONS Debug
+		LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug
+		ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_DEBUG_PATH}${SUFFIX}" CONFIGURATIONS Debug
 		FRAMEWORK DESTINATION "${MYGUI_FRAMEWORK_PATH}" CONFIGURATIONS Debug
 	)
 endfunction(mygui_install_target)
@@ -364,11 +364,11 @@ function(mygui_install_app PROJECTNAME)
 	if (MYGUI_INSTALL_PDB)
 		# install debug pdb files
 		install(FILES ${MYGUI_BINARY_DIR}/bin${MYGUI_DEBUG_PATH}/${PROJECTNAME}.pdb
-			DESTINATION bin${MYGUI_DEBUG_PATH}
+			DESTINATION ${CMAKE_INSTALL_BINDIR}${MYGUI_DEBUG_PATH}
 			CONFIGURATIONS Debug
 		)
 		install(FILES ${MYGUI_BINARY_DIR}/bin${MYGUI_RELWDBG_PATH}/${PROJECTNAME}.pdb
-			DESTINATION bin${MYGUI_RELWDBG_PATH}
+			DESTINATION ${CMAKE_INSTALL_BINDIR}${MYGUI_RELWDBG_PATH}
 			CONFIGURATIONS RelWithDebInfo
 		)
 	endif ()
@@ -400,7 +400,7 @@ function(mygui_plugin PROJECTNAME)
 	set_target_properties(${PROJECTNAME} PROPERTIES PREFIX "")
 
 	install(FILES ${HEADER_FILES}
-		DESTINATION include/MYGUI
+		DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MYGUI
 	)
 endfunction(mygui_plugin)
 
@@ -431,20 +431,20 @@ function(mygui_config_lib PROJECTNAME)
 		# install debug pdb files
 		if (MYGUI_STATIC)
 			install(FILES ${MYGUI_BINARY_DIR}/lib${MYGUI_LIB_DEBUG_PATH}/${PROJECTNAME}Static_d.pdb
-				DESTINATION lib${MYGUI_LIB_DEBUG_PATH}
+				DESTINATION ${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_DEBUG_PATH}
 				CONFIGURATIONS Debug
 			)
 			install(FILES ${MYGUI_BINARY_DIR}/lib${MYGUI_LIB_RELWDBG_PATH}/${PROJECTNAME}Static.pdb
-				DESTINATION lib${MYGUI_LIB_RELWDBG_PATH}
+				DESTINATION ${CMAKE_INSTALL_LIBDIR}${MYGUI_LIB_RELWDBG_PATH}
 				CONFIGURATIONS RelWithDebInfo
 			)
 		else ()
 			install(FILES ${MYGUI_BINARY_DIR}/bin${MYGUI_DEBUG_PATH}/${PROJECTNAME}_d.pdb
-				DESTINATION bin${MYGUI_DEBUG_PATH}
+				DESTINATION ${CMAKE_INSTALL_BINDIR}${MYGUI_DEBUG_PATH}
 				CONFIGURATIONS Debug
 			)
 			install(FILES ${MYGUI_BINARY_DIR}/bin${MYGUI_RELWDBG_PATH}/${PROJECTNAME}.pdb
-				DESTINATION bin${MYGUI_RELWDBG_PATH}
+				DESTINATION ${CMAKE_INSTALL_BINDIR}${MYGUI_RELWDBG_PATH}
 				CONFIGURATIONS RelWithDebInfo
 			)
 		endif ()
@@ -459,7 +459,7 @@ function(mygui_config_sample PROJECTNAME)
 	# set install RPATH for Unix systems
 	if (UNIX AND MYGUI_FULL_RPATH)
 		set_property(TARGET ${PROJECTNAME} APPEND PROPERTY
-			INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
+			INSTALL_RPATH ${CMAKE_INSTALL_LIBDIR})
 		set_property(TARGET ${PROJECTNAME} PROPERTY INSTALL_RPATH_USE_LINK_PATH TRUE)
 	endif ()
 endfunction(mygui_config_sample)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9fc5694..0cddafa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,7 @@ set(CMAKE_MODULE_PATH
 	"${MYGUI_SOURCE_DIR}/CMake/Utils"
 	"${MYGUI_SOURCE_DIR}/CMake/Packages"
 )
+include(GNUInstallDirs)
 include(CMakeDependentOption)
 include(MacroLogFeature)
 include(MyGUIConfigTargets)
diff --git a/MyGUIEngine/CMakeLists.txt b/MyGUIEngine/CMakeLists.txt
index c5eab54..839ff43 100644
--- a/MyGUIEngine/CMakeLists.txt
+++ b/MyGUIEngine/CMakeLists.txt
@@ -64,5 +64,5 @@ endif ()
 
 # install MyGUIEngine headers
 install(FILES ${HEADER_FILES}
-  DESTINATION include/MYGUI
+	DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/MYGUI"
 )
diff --git a/Platforms/OpenGL/OpenGLPlatform/CMakeLists.txt b/Platforms/OpenGL/OpenGLPlatform/CMakeLists.txt
index 169ad05..4bd7cd1 100644
--- a/Platforms/OpenGL/OpenGLPlatform/CMakeLists.txt
+++ b/Platforms/OpenGL/OpenGLPlatform/CMakeLists.txt
@@ -30,7 +30,7 @@ link_directories(${OPENGL_LIB_DIR} ${PNG_LIBRARY})
 
 # installation rules
 install(FILES ${HEADER_FILES}
-        DESTINATION include/MYGUI
+        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MYGUI
 )
 mygui_install_target(${PROJECTNAME} "")
 
-- 
2.8.3