From 1bf29a0ae1fffee8a009dfbc8da2d7c048f6eb20 Mon Sep 17 00:00:00 2001 From: Enan Ajmain <3nan.ajmain@gmail.com> Date: Sun, 7 May 2023 04:47:45 +0600 Subject: [PATCH] build: add system lua include dir for lpeg Problem: Lpeg requires Lua headers. Currently the include directories for Lpeg are set only to the bundled deps folder, so if the user wants to use system Lua/Luajit, Lpeg will not find the system headers and will fail to build. Solution: Add system Lua/Luajit include directories when USE_BUNDLED_LUA and USE_BUNDLED_LUAJIT are turned off. Fixes #23469 --- cmake.deps/cmake/BuildLpeg.cmake | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cmake.deps/cmake/BuildLpeg.cmake b/cmake.deps/cmake/BuildLpeg.cmake index 81efccf1f4..bbdc83d94d 100644 --- a/cmake.deps/cmake/BuildLpeg.cmake +++ b/cmake.deps/cmake/BuildLpeg.cmake @@ -1,4 +1,18 @@ -list(APPEND LPEG_CMAKE_ARGS "-DCMAKE_C_FLAGS:STRING=${DEPS_INCLUDE_FLAGS}") +set(LPEG_INCLUDE_FLAGS ${DEPS_INCLUDE_FLAGS}) + +if(NOT USE_BUNDLED_LUAJIT AND NOT USE_BUNDLED_LUA) + find_package(Luajit) + if(LUAJIT_FOUND) + string(CONCAT LPEG_INCLUDE_FLAGS ${DEPS_INCLUDE_FLAGS} " -I${LUAJIT_INCLUDE_DIR}") + else() + find_package(Lua 5.1 EXACT) + if(LUA_FOUND) + string(CONCAT LPEG_INCLUDE_FLAGS ${DEPS_INCLUDE_FLAGS} " -I${LUA_INCLUDE_DIR}") + endif() + endif() +endif() + +list(APPEND LPEG_CMAKE_ARGS -DCMAKE_C_FLAGS=${LPEG_INCLUDE_FLAGS}) ExternalProject_Add(lpeg URL ${LPEG_URL}