Skip to content

Commit dd868a9

Browse files
committed
cmake: Findthrift.cmake parses version string
when thrift headers are found, parse the version string into a cmake variable and pass it to find_package_handle_standard_args this will be needed by BuildArrow.cmake for some conditional logic Signed-off-by: Casey Bodley <[email protected]>
1 parent 3d844bc commit dd868a9

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

cmake/modules/Findthrift.cmake

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,19 @@ find_library(
1717
HINTS ${thrift_HOME} ENV thrift_HOME /usr/local /opt/local
1818
PATH_SUFFIXES lib lib64)
1919

20+
if(thrift_INCLUDE_DIR)
21+
file(READ "${thrift_INCLUDE_DIR}/thrift/config.h" THRIFT_CONFIG_H_CONTENT)
22+
string(REGEX MATCH "#define PACKAGE_VERSION \"[0-9.]+\"" THRIFT_VERSION_DEFINITION
23+
"${THRIFT_CONFIG_H_CONTENT}")
24+
string(REGEX MATCH "[0-9.]+" thrift_VERSION "${THRIFT_VERSION_DEFINITION}")
25+
set(thrift_VERSION "${thrift_VERSION}" PARENT_SCOPE)
26+
endif()
27+
2028
include(FindPackageHandleStandardArgs)
21-
find_package_handle_standard_args(thrift DEFAULT_MSG thrift_LIBRARIES
22-
thrift_INCLUDE_DIR)
29+
find_package_handle_standard_args(
30+
thrift
31+
REQUIRED_VARS thrift_LIBRARIES thrift_INCLUDE_DIR
32+
VERSION_VAR thrift_VERSION)
2333
mark_as_advanced(thrift_LIBRARIES thrift_INCLUDE_DIR)
2434

2535
if(thrift_FOUND AND NOT (TARGET thrift::libthrift))

0 commit comments

Comments
 (0)