From fe1f69ab2ec31fb9c9bd17d6fc684b9179c493f6 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Thu, 27 Apr 2023 09:48:04 +0900 Subject: THRIFT-5668: Install FindLibevent.cmake (#2726) Client: cpp ThriftConfig.cmake uses our FindLibevent.cmake but "make install" doesn't install FindLibevent.cmake. It causes an error with find_package(Thrift) like the following: -- Found thrift: /tmp/xxx/tmp/local -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.13") -- Found OpenSSL: /usr/lib/x86_64-linux-gnu/libcrypto.so (found version "3.0.7") CMake Warning at /usr/share/cmake-3.24/Modules/CMakeFindDependencyMacro.cmake:47 (find_package): By not providing "FindLibevent.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Libevent", but CMake did not find one. Could not find a package configuration file provided by "Libevent" with any of the following names: LibeventConfig.cmake libevent-config.cmake Add the installation prefix of "Libevent" to CMAKE_PREFIX_PATH or set "Libevent_DIR" to a directory containing one of the above files. If "Libevent" provides a separate development package or SDK, be sure it has been installed. Call Stack (most recent call first): /tmp/xxx/tmp/local/lib/cmake/thrift/ThriftConfig.cmake:93 (find_dependency) --- build/cmake/GenerateConfigModule.cmake | 1 + build/cmake/ThriftConfig.cmake.in | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/build/cmake/GenerateConfigModule.cmake b/build/cmake/GenerateConfigModule.cmake index 9533c8235..26f018a21 100644 --- a/build/cmake/GenerateConfigModule.cmake +++ b/build/cmake/GenerateConfigModule.cmake @@ -40,5 +40,6 @@ if (NOT CYGWIN) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ThriftConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/ThriftConfigVersion.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/FindLibevent.cmake" DESTINATION "${CMAKE_INSTALL_DIR}/thrift") endif() diff --git a/build/cmake/ThriftConfig.cmake.in b/build/cmake/ThriftConfig.cmake.in index c05520094..2f2003bb4 100644 --- a/build/cmake/ThriftConfig.cmake.in +++ b/build/cmake/ThriftConfig.cmake.in @@ -59,7 +59,19 @@ if(@OPENSSL_FOUND@ AND @WITH_OPENSSL@) endif() if(@Libevent_FOUND@ AND @WITH_LIBEVENT@) + if(DEFINED CMAKE_MODULE_PATH) + set(THRIFT_CMAKE_MODULE_PATH_OLD ${CMAKE_MODULE_PATH}) + else() + unset(THRIFT_CMAKE_MODULE_PATH_OLD) + endif() + set(CMAKE_MODULE_PATH "${THRIFT_CMAKE_DIR}") find_dependency(Libevent) + if(DEFINED THRIFT_CMAKE_MODULE_PATH_OLD) + set(CMAKE_MODULE_PATH ${THRIFT_CMAKE_MODULE_PATH_OLD}) + unset(THRIFT_CMAKE_MODULE_PATH_OLD) + else() + unset(CMAKE_MODULE_PATH) + endif() endif() check_required_components(Thrift) -- cgit v1.2.1