From: Ole Streicher <olebole@debian.org>
Date: Tue, 14 Jul 2020 15:46:16 +0200
Subject: Install files in standard Debian paths

---
 CMakeLists.txt             |  6 +++---
 GFTL_SHARED.mk.in          | 10 +++++-----
 GFTL_SHAREDConfig.cmake.in |  4 +---
 src/CMakeLists.txt         | 10 +++++-----
 4 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8861700..b5f53e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,10 +40,10 @@ add_subdirectory (src)
 configure_file (GFTL_SHAREDConfig-version.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDConfig-version.cmake @ONLY)
 configure_file (GFTL_SHAREDConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDConfig.cmake @ONLY)
 
-set (top_dir GFTL_SHARED-${GFTL_SHARED_VERSION_MAJOR}.${GFTL_SHARED_VERSION_MINOR})
+set (top_dir gftl_shared)
 install (
   FILES ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDConfig-version.cmake
-  DESTINATION "${top_dir}/cmake")
+  DESTINATION "share/cmake/${top_dir}")
 
 # The following is needed for external projects using *nix make when
 # parent project builds gFTL-shared as a subproject.
@@ -51,5 +51,5 @@ set (GFTL_SHARED_TOP_DIR "${CMAKE_INSTALL_PREFIX}/${top_dir}" CACHE PATH "")
 configure_file (GFTL_SHARED.mk.in ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHARED.mk @ONLY)
 install (
   FILES ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHARED.mk ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHARED.mk
-  DESTINATION "${top_dir}/include")
+  DESTINATION "share/gftl_shared")
 
diff --git a/GFTL_SHARED.mk.in b/GFTL_SHARED.mk.in
index b5d5fef..02349a0 100644
--- a/GFTL_SHARED.mk.in
+++ b/GFTL_SHARED.mk.in
@@ -6,14 +6,14 @@
 
 # gFTL
 
-GFTL_TOP_DIR := @GFTL_TOP_DIR@
-include ${GFTL_TOP_DIR}/include/GFTL.mk
+GFTL_TOP_DIR := @CMAKE_INSTALL_PREFIX@
+include ${GFTL_TOP_DIR}/share/gftl/GFTL.mk
 
 # gFTL-shared
 GFTL_SHARED_INSTALL_PREFIX := @CMAKE_INSTALL_PREFIX@
 GFTL_SHARED_VERSION := @GFTL_SHARED_VERSION_MAJOR@.@GFTL_SHARED_VERSION_MINOR@
-GFTL_SHARED_TOP_DIR := $(GFTL_SHARED_INSTALL_PREFIX)/GFTL_SHARED-$(GFTL_SHARED_VERSION)
-GFTL_SHARED_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include
-GFTL_SHARED_LIBRARIES := -L$(GFTL_SHARED_TOP_DIR)/lib -lgftl-shared
+GFTL_SHARED_TOP_DIR := $(GFTL_SHARED_INSTALL_PREFIX)
+GFTL_SHARED_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include/gftl_shared
+GFTL_SHARED_LIBRARIES := -lgftl-shared
 
 
diff --git a/GFTL_SHAREDConfig.cmake.in b/GFTL_SHAREDConfig.cmake.in
index 612bc02..3dc126a 100644
--- a/GFTL_SHAREDConfig.cmake.in
+++ b/GFTL_SHAREDConfig.cmake.in
@@ -1,7 +1,5 @@
 # Package configuration file
 
 get_filename_component (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
-set (PREFIX ${SELF_DIR}/../..)
-set (GFTL_SHARED_TOP_DIR ${PREFIX}/GFTL_SHARED-@GFTL_SHARED_VERSION_MAJOR@.@GFTL_SHARED_VERSION_MINOR@ CACHE PATH "")
-include ("${GFTL_SHARED_TOP_DIR}/cmake/GFTL_SHARED.cmake")
+include ("${SELF_DIR}/GFTL_SHARED.cmake")
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c298f01..ea1ef88 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -143,11 +143,11 @@ if (_ISO_REAL128)
   endif ()
 endif()
 
-set (dest "GFTL_SHARED-${GFTL_SHARED_VERSION_MAJOR}.${GFTL_SHARED_VERSION_MINOR}")
+set (dest "gftl_shared")
 
 target_include_directories (gftl-shared PUBLIC
   $<BUILD_INTERFACE:${GFTL_SHARED_BINARY_DIR}/mod>
-  $<INSTALL_INTERFACE:${dest}/include>
+  $<INSTALL_INTERFACE:include/${dest}>
   )
 
 target_link_libraries (gftl-shared extern-gftl-shared)
@@ -155,8 +155,8 @@ target_link_libraries (gftl-shared extern-gftl-shared)
 add_executable (demo.x demo.F90)
 target_link_libraries (demo.x gftl-shared)
 
-install (DIRECTORY ${GFTL_SHARED_BINARY_DIR}/mod/ DESTINATION ${dest}/include)
-install (TARGETS gftl-shared EXPORT GFTL_SHARED DESTINATION "${dest}/lib")
-install (EXPORT GFTL_SHARED DESTINATION "${dest}/cmake")
+install (DIRECTORY ${GFTL_SHARED_BINARY_DIR}/mod/ DESTINATION include/${dest})
+install (TARGETS gftl-shared EXPORT GFTL_SHARED DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+install (EXPORT GFTL_SHARED DESTINATION "share/cmake/${dest}")
 
 
