diff options
author | Ivan Ivanov <anonim288@gmail.com> | 2016-06-20 16:53:45 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-06-20 18:46:06 (GMT) |
commit | eecd307e24a35b68d7ed4fa2f085c283d3e34461 (patch) | |
tree | 8ffd5f3683aa35264983f3d8297c4c294d8c6f69 /Modules/FindLua.cmake | |
parent | 3532cbce18f4021507a0fd8d23d0930aa09ae8e1 (diff) | |
download | CMake-eecd307e24a35b68d7ed4fa2f085c283d3e34461.zip CMake-eecd307e24a35b68d7ed4fa2f085c283d3e34461.tar.gz CMake-eecd307e24a35b68d7ed4fa2f085c283d3e34461.tar.bz2 |
FindLua: Iterate through all include subdirs to find a suitable header
Fixes #15756.
Diffstat (limited to 'Modules/FindLua.cmake')
-rw-r--r-- | Modules/FindLua.cmake | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/Modules/FindLua.cmake b/Modules/FindLua.cmake index 4af3bbf..f105f3d 100644 --- a/Modules/FindLua.cmake +++ b/Modules/FindLua.cmake @@ -77,6 +77,8 @@ function(_lua_set_version_vars) set(_lua_append_versions ${LUA_VERSIONS5}) endif () + list(APPEND _lua_include_subdirs "include/lua" "include") + foreach (ver IN LISTS _lua_append_versions) string(REGEX MATCH "^([0-9]+)\\.([0-9]+)$" _ver "${ver}") list(APPEND _lua_include_subdirs @@ -131,18 +133,33 @@ endfunction(_lua_check_header_version) _lua_set_version_vars() -find_path(LUA_INCLUDE_DIR lua.h - HINTS - ENV LUA_DIR - PATH_SUFFIXES ${_lua_include_subdirs} include/lua include - PATHS - ~/Library/Frameworks - /Library/Frameworks - /sw # Fink - /opt/local # DarwinPorts - /opt/csw # Blastwave - /opt -) +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 + ENV LUA_DIR + PATHS + ~/Library/Frameworks + /Library/Frameworks + /sw # Fink + /opt/local # DarwinPorts + /opt/csw # Blastwave + /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_append_versions) @@ -172,10 +189,6 @@ if (LUA_LIBRARY) 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) # handle the QUIETLY and REQUIRED arguments and set LUA_FOUND to TRUE if # all listed variables are TRUE |