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}