--- CMakeLists.txt.orig	2023-07-21 20:50:14.000000000 +0800
+++ CMakeLists.txt	2023-10-18 15:46:18.000000000 +0800
@@ -21,7 +21,7 @@
 # Below, the default is changed to a directory within the build tree
 # unless the user explicitly sets CMAKE_INSTALL_PREFIX in the cache.
 if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-    set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed" CACHE PATH "default install path" FORCE )
+    set (CMAKE_INSTALL_PREFIX "@PREFIX@" CACHE PATH "default install path" FORCE)
 endif()
 
 
@@ -35,17 +35,14 @@
 include(${CMAKE_Fortran_COMPILER_ID} RESULT_VARIABLE found)
 include(check_intrinsic_kinds RESULT_VARIABLE found)
 
-# We attempt to use find_package() first for each dependency.  But all
-# dependencies are also available as submodules.
-include(build_submodule)
-build_submodule(extern/gFTL PROJECT GFTL TARGET GFTL::gftl)
+find_package(GFTL REQUIRED)
 
 add_subdirectory (src)
 
 # The following is needed for external projects using *nix make when
 # parent project builds gFTL-shared as a subproject.
-set (top_dir GFTL_SHARED-${GFTL_SHARED_VERSION_MAJOR}.${GFTL_SHARED_VERSION_MINOR})
-set (GFTL_SHARED_TOP_DIR "${CMAKE_INSTALL_PREFIX}/${top_dir}" CACHE PATH "")
+set (top_dir "GFTL_SHARED")
+set (GFTL_SHARED_TOP_DIR "${CMAKE_INSTALL_PREFIX}" CACHE PATH "")
 
 include(CMakePackageConfigHelpers)
 configure_package_config_file(GFTL_SHAREDConfig.cmake.in GFTL_SHAREDConfig.cmake
@@ -58,17 +55,17 @@
 
 install (
   FILES ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDConfig-version.cmake
-  DESTINATION "${top_dir}/cmake")
+  DESTINATION "lib/cmake")
 
 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 "${GFTL_SHARED_TOP_DIR}/include/${top_dir}")
 
 install(EXPORT GFTL_SHARED
   FILE GFTL_SHAREDTargets.cmake
   NAMESPACE GFTL_SHARED::
-  DESTINATION "${top_dir}/cmake"
+  DESTINATION "lib/cmake"
   )
 export(EXPORT GFTL_SHARED
   FILE "${CMAKE_CURRENT_BINARY_DIR}/GFTL_SHAREDTargets.cmake"

--- GFTL_SHARED.mk.in.orig	2023-07-21 20:50:14.000000000 +0800
+++ GFTL_SHARED.mk.in	2023-10-18 15:48:10.000000000 +0800
@@ -1,4 +1,4 @@
-# Include file for external  projects using Unix Make instead of cmake.
+# Include file for external projects using Unix Make instead of cmake.
 # Usage:
 
 # FFLAGS += -I$(GFTL_INCLUDE_DIR) -I$(GFTL_SHARED_INCLUDE_DIR)
@@ -11,13 +11,10 @@
 
 # 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/v1
-GFTL_SHARED_V1_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include/v1
-GFTL_SHARED_V2_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include/v2
+GFTL_SHARED_TOP_DIR := $(GFTL_SHARED_INSTALL_PREFIX)
+GFTL_SHARED_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include/GFTL_SHARED/v1
+GFTL_SHARED_V1_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include/GFTL_SHARED/v1
+GFTL_SHARED_V2_INCLUDE_DIR := $(GFTL_SHARED_TOP_DIR)/include/GFTL_SHARED/v2
 GFTL_SHARED_LIBRARIES := -L$(GFTL_SHARED_TOP_DIR)/lib -lgftl-shared-v1
 GFTL_SHARED_V1_LIBRARIES := -L$(GFTL_SHARED_TOP_DIR)/lib -lgftl-shared-v1
 GFTL_SHARED_V2_LIBRARIES := -L$(GFTL_SHARED_TOP_DIR)/lib -lgftl-shared-v2
-
-

--- src/v1/CMakeLists.txt.orig	2023-07-21 20:50:14.000000000 +0800
+++ src/v1/CMakeLists.txt	2023-10-18 15:45:37.000000000 +0800
@@ -66,11 +66,11 @@
   endif ()
 endif()
 
-set (dest "GFTL_SHARED-${GFTL_SHARED_VERSION_MAJOR}.${GFTL_SHARED_VERSION_MINOR}")
+set (dest "include/GFTL_SHARED")
 
 target_include_directories (gftl-shared-v1 PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
-  $<INSTALL_INTERFACE:${dest}/include/v1>
+  $<INSTALL_INTERFACE:${dest}/v1>
   )
 
 if (GFTL::gftl-v1)
@@ -82,5 +82,5 @@
 add_executable (demo.x demo.F90)
 target_link_libraries (demo.x gftl-shared-v1)
 
-install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod/ DESTINATION ${dest}/include/v1)
-install (TARGETS gftl-shared-v1 gftl-shared EXPORT GFTL_SHARED DESTINATION "${dest}/lib")
+install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod/ DESTINATION "${dest}/v1")
+install (TARGETS gftl-shared-v1 gftl-shared EXPORT GFTL_SHARED DESTINATION "${CMAKE_INSTALL_LIBDIR}")

--- src/v2/CMakeLists.txt	2024-07-09 22:46:42.000000000 +0800
+++ src/v2/CMakeLists.txt	2024-08-08 13:12:02.000000000 +0800
@@ -140,11 +140,11 @@
   endif ()
 endif()
 
-set (dest "GFTL_SHARED-${GFTL_SHARED_VERSION_MAJOR}.${GFTL_SHARED_VERSION_MINOR}")
+set (dest "include/GFTL_SHARED")
 
 target_include_directories (gftl-shared-v2 PUBLIC
   $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/mod>
-  $<INSTALL_INTERFACE:${dest}/include/v2>
+  $<INSTALL_INTERFACE:${dest}/v2>
   )
 
 target_link_libraries (gftl-shared-v2 PUBLIC GFTL::gftl-v2)
@@ -152,6 +152,6 @@
 #add_executable (demo.x demo.F90)
 #target_link_libraries (demo.x gftl-shared-v2)
 
-install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod/ DESTINATION ${dest}/include/v2)
-install (TARGETS gftl-shared-v2 EXPORT GFTL_SHARED DESTINATION "${dest}/lib")
+install (DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mod/ DESTINATION "${dest}/v2")
+install (TARGETS gftl-shared-v2 EXPORT GFTL_SHARED DESTINATION "${CMAKE_INSTALL_LIBDIR}")
 install (TARGETS ${v2-default} EXPORT GFTL_SHARED DESTINATION "${dest}/lib")
