THRIFT-5667: Make ThriftConfig.cmake relocatable

Client: cpp

The current ThriftConfig.cmake isn't relocatable. It means that we
can't move ThriftConfig.cmake installed by "make install".

In general, users don't need to move ThriftConfig.cmake installed by
"make install" but some packaging systems such as conda and MSYS2 needs
to move. Because users of these packaging systems may use different
prefix. For example, conda may be used with ~alice/my-conda and
~bob/conda as base directory.

CMake has a feature to make Config.cmake relocatable:
https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html

We can use it to make ThriftConfig.cmake relocatable.
diff --git a/build/cmake/GenerateConfigModule.cmake b/build/cmake/GenerateConfigModule.cmake
index 597ffd8..15c0942 100644
--- a/build/cmake/GenerateConfigModule.cmake
+++ b/build/cmake/GenerateConfigModule.cmake
@@ -18,19 +18,16 @@
 #
 
 include(CMakePackageConfigHelpers)
-set(PACKAGE_INCLUDE_INSTALL_DIR "${includedir}/thrift")
-set(PACKAGE_CMAKE_INSTALL_DIR "${cmakedir}/thrift")
-set(PACKAGE_BIN_INSTALL_DIR "${exec_prefix}")
 
-# In CYGWIN enviroment below commands does not work properly
+# In CYGWIN environment below commands does not work properly
 if (NOT CYGWIN)
 		configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/ThriftConfig.cmake.in"
 						"${CMAKE_CURRENT_BINARY_DIR}/ThriftConfig.cmake"
 						INSTALL_DESTINATION "${CMAKE_INSTALL_DIR}/thrift"
 						PATH_VARS
-						PACKAGE_INCLUDE_INSTALL_DIR
-						PACKAGE_CMAKE_INSTALL_DIR
-						PACKAGE_BIN_INSTALL_DIR
+						INCLUDE_INSTALL_DIR
+						CMAKE_INSTALL_DIR
+						BIN_INSTALL_DIR
 						)
 
 		write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/ThriftConfigVersion.cmake"
diff --git a/build/cmake/ThriftConfig.cmake.in b/build/cmake/ThriftConfig.cmake.in
index f132fe1..7c12c3f 100644
--- a/build/cmake/ThriftConfig.cmake.in
+++ b/build/cmake/ThriftConfig.cmake.in
@@ -21,8 +21,9 @@
 
 @PACKAGE_INIT@
 
-set_and_check(THRIFT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
-set_and_check(THRIFT_CMAKE_DIR "@PACKAGE_CMAKE_INSTALL_DIR@")
+set_and_check(THRIFT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
+
+set_and_check(THRIFT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@/thrift")
 set_and_check(THRIFT_BIN_DIR "@PACKAGE_BIN_INSTALL_DIR@")
 if(NOT DEFINED THRIFT_COMPILER)
     set(THRIFT_COMPILER "${THRIFT_BIN_DIR}/thrift@CMAKE_EXECUTABLE_SUFFIX@")