Build: cmake: fixes #26247 update cmake to work with new required dep lark for BIM (#26407)

This commit is contained in:
Chris
2026-01-11 19:55:38 -06:00
committed by GitHub
parent 419e1822b8
commit 12d1dba109
4 changed files with 67 additions and 0 deletions

53
cMake/FindLARK.cmake Normal file
View File

@@ -0,0 +1,53 @@
# - Find the lark library
# This module finds if lark is installed, and sets the following variables
# indicating where it is.
#
# LARK_FOUND - was lark found
# LARK_VERSION - the version of lark found as a string
# LARK_VERSION_MAJOR - the major version number of lark
# LARK_VERSION_MINOR - the minor version number of lark
# LARK_VERSION_PATCH - the patch version number of lark
include(FindPackageHandleStandardArgs)
if(Python3_EXECUTABLE)
message(STATUS "FindLark: Using Python3_EXECUTABLE = ${Python3_EXECUTABLE}")
# try to import lark into Python interpreter
execute_process(
COMMAND "${Python3_EXECUTABLE}" "-c"
"import lark; print(lark.__version__)"
RESULT_VARIABLE _LARK_SEARCH_SUCCESS
OUTPUT_VARIABLE LARK_VERSION
ERROR_VARIABLE _LARK_ERROR_VALUE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(DEBUG "FindLark: Result = ${_LARK_SEARCH_SUCCESS}")
message(DEBUG "FindLark: Version = ${LARK_VERSION}")
message(DEBUG "FindLark: Error = ${_LARK_ERROR_VALUE}")
if(_LARK_SEARCH_SUCCESS MATCHES 0)
# extract version components
string(REGEX REPLACE "\\." ";" _LARK_VERSION_LIST ${LARK_VERSION})
list(LENGTH _LARK_VERSION_LIST _LARK_VERSION_LIST_LEN)
if(_LARK_VERSION_LIST_LEN GREATER_EQUAL 1)
list(GET _LARK_VERSION_LIST 0 LARK_VERSION_MAJOR)
endif()
if(_LARK_VERSION_LIST_LEN GREATER_EQUAL 2)
list(GET _LARK_VERSION_LIST 1 LARK_VERSION_MINOR)
endif()
if(_LARK_VERSION_LIST_LEN GREATER_EQUAL 3)
list(GET _LARK_VERSION_LIST 2 LARK_VERSION_PATCH)
endif()
else()
message(STATUS "The BIM workbench requires the lark python package / module to be installed")
endif()
else()
message(STATUS "FindLark: Python3_EXECUTABLE not set")
endif()
find_package_handle_standard_args(LARK
REQUIRED_VARS LARK_VERSION
VERSION_VAR LARK_VERSION
)

View File

@@ -221,6 +221,9 @@ macro(PrintFinalReport)
conditional(fmt fmt_FOUND "Sources downloaded to ${fmt_SOURCE_DIR}" "${fmt_VERSION}")
conditional(yaml-cpp yaml-cpp_FOUND "not found" "${yaml-cpp_VERSION}")
conditional(Vtk VTK_FOUND "not found" ${VTK_VERSION})
if(BUILD_BIM)
conditional(Lark LARK_FOUND "not found" "${LARK_VERSION}")
endif()
section_end()

View File

@@ -0,0 +1,7 @@
macro(SetupLark)
# ------------------------------ Lark ------------------------------
find_package(LARK MODULE REQUIRED)
message(STATUS "Found Lark: version ${LARK_VERSION}")
endmacro()