Skip to content

Commit 951bb18

Browse files
kouJens-G
authored andcommitted
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.
1 parent 24df0a5 commit 951bb18

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

build/cmake/GenerateConfigModule.cmake

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,16 @@
1818
#
1919

2020
include(CMakePackageConfigHelpers)
21-
set(PACKAGE_INCLUDE_INSTALL_DIR "${includedir}/thrift")
22-
set(PACKAGE_CMAKE_INSTALL_DIR "${cmakedir}/thrift")
23-
set(PACKAGE_BIN_INSTALL_DIR "${exec_prefix}")
2421

25-
# In CYGWIN enviroment below commands does not work properly
22+
# In CYGWIN environment below commands does not work properly
2623
if (NOT CYGWIN)
2724
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/ThriftConfig.cmake.in"
2825
"${CMAKE_CURRENT_BINARY_DIR}/ThriftConfig.cmake"
2926
INSTALL_DESTINATION "${CMAKE_INSTALL_DIR}/thrift"
3027
PATH_VARS
31-
PACKAGE_INCLUDE_INSTALL_DIR
32-
PACKAGE_CMAKE_INSTALL_DIR
33-
PACKAGE_BIN_INSTALL_DIR
28+
INCLUDE_INSTALL_DIR
29+
CMAKE_INSTALL_DIR
30+
BIN_INSTALL_DIR
3431
)
3532

3633
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/ThriftConfigVersion.cmake"

build/cmake/ThriftConfig.cmake.in

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ set(THRIFT_VERSION @thrift_VERSION@)
2121

2222
@PACKAGE_INIT@
2323

24-
set_and_check(THRIFT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
25-
set_and_check(THRIFT_CMAKE_DIR "@PACKAGE_CMAKE_INSTALL_DIR@")
24+
set_and_check(THRIFT_CMAKE_DIR "${CMAKE_CURRENT_LIST_DIR}")
25+
26+
set_and_check(THRIFT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@/thrift")
2627
set_and_check(THRIFT_BIN_DIR "@PACKAGE_BIN_INSTALL_DIR@")
2728
if(NOT DEFINED THRIFT_COMPILER)
2829
set(THRIFT_COMPILER "${THRIFT_BIN_DIR}/thrift@CMAKE_EXECUTABLE_SUFFIX@")

0 commit comments

Comments
 (0)