FindLua: Iterate through all include subdirs to find a suitable header
Fixes #15756.
This commit is contained in:
parent
3532cbce18
commit
eecd307e24
|
@ -77,6 +77,8 @@ function(_lua_set_version_vars)
|
||||||
set(_lua_append_versions ${LUA_VERSIONS5})
|
set(_lua_append_versions ${LUA_VERSIONS5})
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
list(APPEND _lua_include_subdirs "include/lua" "include")
|
||||||
|
|
||||||
foreach (ver IN LISTS _lua_append_versions)
|
foreach (ver IN LISTS _lua_append_versions)
|
||||||
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
|
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}")
|
||||||
list(APPEND _lua_include_subdirs
|
list(APPEND _lua_include_subdirs
|
||||||
|
@ -131,10 +133,16 @@ endfunction(_lua_check_header_version)
|
||||||
|
|
||||||
_lua_set_version_vars()
|
_lua_set_version_vars()
|
||||||
|
|
||||||
find_path(LUA_INCLUDE_DIR lua.h
|
if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
||||||
|
_lua_check_header_version("${LUA_INCLUDE_DIR}/lua.h")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT LUA_VERSION_STRING)
|
||||||
|
foreach (subdir IN LISTS _lua_include_subdirs)
|
||||||
|
unset(LUA_INCLUDE_PREFIX CACHE)
|
||||||
|
find_path(LUA_INCLUDE_PREFIX ${subdir}/lua.h
|
||||||
HINTS
|
HINTS
|
||||||
ENV LUA_DIR
|
ENV LUA_DIR
|
||||||
PATH_SUFFIXES ${_lua_include_subdirs} include/lua include
|
|
||||||
PATHS
|
PATHS
|
||||||
~/Library/Frameworks
|
~/Library/Frameworks
|
||||||
/Library/Frameworks
|
/Library/Frameworks
|
||||||
|
@ -143,6 +151,15 @@ find_path(LUA_INCLUDE_DIR lua.h
|
||||||
/opt/csw # Blastwave
|
/opt/csw # Blastwave
|
||||||
/opt
|
/opt
|
||||||
)
|
)
|
||||||
|
if (LUA_INCLUDE_PREFIX)
|
||||||
|
_lua_check_header_version("${LUA_INCLUDE_PREFIX}/${subdir}/lua.h")
|
||||||
|
if (LUA_VERSION_STRING)
|
||||||
|
set(LUA_INCLUDE_DIR "${LUA_INCLUDE_PREFIX}/${subdir}")
|
||||||
|
break()
|
||||||
|
endif ()
|
||||||
|
endif ()
|
||||||
|
endforeach ()
|
||||||
|
endif ()
|
||||||
unset(_lua_include_subdirs)
|
unset(_lua_include_subdirs)
|
||||||
unset(_lua_append_versions)
|
unset(_lua_append_versions)
|
||||||
|
|
||||||
|
@ -172,10 +189,6 @@ if (LUA_LIBRARY)
|
||||||
endif ()
|
endif ()
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (LUA_INCLUDE_DIR AND EXISTS "${LUA_INCLUDE_DIR}/lua.h")
|
|
||||||
_lua_check_header_version("${LUA_INCLUDE_DIR}/lua.h")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
|
||||||
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
# handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if
|
||||||
# all listed variables are TRUE
|
# all listed variables are TRUE
|
||||||
|
|
Loading…
Reference in New Issue