Skip to content

Commit

Permalink
CMake: better version parsing for CLN (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
volkm authored Feb 13, 2024
1 parent 58e3eca commit c5484ae
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cmake/FindCLN.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ find_library(CLN_LIBRARY
if(CLN_INCLUDE_DIR AND CLN_LIBRARY)
set(CLN_FOUND TRUE)

# Version
file(STRINGS ${CLN_INCLUDE_DIR}/cln/version.h CLN_VERSION REGEX "^#define[\t ]+CL_VERSION .*")
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CLN_VERSION "${CLN_VERSION}")
# Parse version
file(STRINGS ${CLN_INCLUDE_DIR}/cln/version.h CLN_VERSION_MAJOR REGEX "^#define[\t ]+CL_VERSION_MAJOR .*")
file(STRINGS ${CLN_INCLUDE_DIR}/cln/version.h CLN_VERSION_MINOR REGEX "^#define[\t ]+CL_VERSION_MINOR .*")
file(STRINGS ${CLN_INCLUDE_DIR}/cln/version.h CLN_VERSION_PATCH REGEX "^#define[\t ]+CL_VERSION_PATCHLEVEL .*")
string(REGEX MATCH "[0-9]+" CLN_VERSION_MAJOR "${CLN_VERSION_MAJOR}")
string(REGEX MATCH "[0-9]+" CLN_VERSION_MINOR "${CLN_VERSION_MINOR}")
string(REGEX MATCH "[0-9]+" CLN_VERSION_PATCH "${CLN_VERSION_PATCH}")
set(CLN_VERSION "${CLN_VERSION_MAJOR}.${CLN_VERSION_MINOR}.${CLN_VERSION_PATCH}")

if(CLN_FIND_VERSION VERSION_GREATER CLN_VERSION)
message(WARNING "Required CLN ${CLN_FIND_VERSION} but found only CLN ${CLN_VERSION}.")
Expand Down

0 comments on commit c5484ae

Please sign in to comment.