comparison OrthancFramework/Resources/CMake/LuaConfiguration.cmake @ 4649:e915102093de

New CMake option: "ORTHANC_LUA_VERSION" to use a specific version of system-wide Lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 30 Apr 2021 10:09:50 +0200
parents d9473bd5ed43
children 7053502fbf97
comparison
equal deleted inserted replaced
4648:56315be75a92 4649:e915102093de
118 ${LUA_SOURCES_DIR}/src/linit.c 118 ${LUA_SOURCES_DIR}/src/linit.c
119 ) 119 )
120 120
121 source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*) 121 source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*)
122 122
123 elseif (CMAKE_CROSSCOMPILING AND 123 elseif ((CMAKE_CROSSCOMPILING AND
124 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg") 124 "${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg") OR
125 NOT "${ORTHANC_LUA_VERSION}" STREQUAL "")
125 126
126 set(LUA_VERSIONS 5.3 5.2 5.1) 127 if ("${ORTHANC_LUA_VERSION}" STREQUAL "")
128 set(LUA_VERSIONS 5.3 5.2 5.1)
129 else()
130 # New in Orthanc 1.9.3
131 set(LUA_VERSIONS ${ORTHANC_LUA_VERSION})
132 endif()
127 133
128 unset(LUA_VERSION) 134 unset(LUA_VERSION)
129 foreach(version IN ITEMS ${LUA_VERSIONS}) 135 foreach(version IN ITEMS ${LUA_VERSIONS})
130 CHECK_INCLUDE_FILE(lua${version}/lua.h HAVE_LUA${version}_H) 136 CHECK_INCLUDE_FILE(lua${version}/lua.h HAVE_LUA${version}_H)
131 if (HAVE_LUA${version}_H) 137 if (HAVE_LUA${version}_H)
136 142
137 if (NOT LUA_VERSION) 143 if (NOT LUA_VERSION)
138 message(FATAL_ERROR "Please install the liblua-dev package") 144 message(FATAL_ERROR "Please install the liblua-dev package")
139 endif() 145 endif()
140 146
141 CHECK_LIBRARY_EXISTS(lua${LUA_VERSION} "lua_call" "${LUA_LIB_DIR}" HAVE_LUA_LIB) 147 if ("${CMAKE_SYSTEM_VERSION}" STREQUAL "CrossToolNg")
142 if (NOT HAVE_LUA_LIB) 148 set(LUA_INCLUDE_DIR ${CROSSTOOL_NG_IMAGE}/usr/include/lua${LUA_VERSION})
149 else()
150 # New in Orthanc 1.9.3
151 find_path(LUA_INCLUDE_DIR
152 NAMES lua.h
153 PATHS
154 /usr/include/lua${LUA_VERSION}
155 /usr/local/include/lua${LUA_VERSION}
156 )
157 endif()
158
159 message("Lua include dir: ${LUA_INCLUDE_DIR}")
160 include_directories(${LUA_INCLUDE_DIR})
161
162 CHECK_LIBRARY_EXISTS(lua${LUA_VERSION} "lua_call" "${LUA_LIB_DIR}" HAVE_LUA_LIB_1) # Lua 5.1
163 CHECK_LIBRARY_EXISTS(lua${LUA_VERSION} "lua_callk" "${LUA_LIB_DIR}" HAVE_LUA_LIB_2) # Lua 5.3
164 if (NOT HAVE_LUA_LIB_1 AND NOT HAVE_LUA_LIB_2)
143 message(FATAL_ERROR "Please install the liblua package") 165 message(FATAL_ERROR "Please install the liblua package")
144 endif() 166 endif()
145 167
146 include_directories(${CROSSTOOL_NG_IMAGE}/usr/include/lua${LUA_VERSION})
147 link_libraries(lua${LUA_VERSION}) 168 link_libraries(lua${LUA_VERSION})
148 169
149 else() 170 else()
150 include(FindLua) 171 include(FindLua)
151 172
152 if (NOT LUA_FOUND) 173 if (NOT LUA_FOUND)
153 message(FATAL_ERROR "Please install the liblua-dev package") 174 message(FATAL_ERROR "Please install the liblua-dev package")
154 endif() 175 endif()
155 176
156 include_directories(${LUA_INCLUDE_DIR}) 177 include_directories(${LUA_INCLUDE_DIR})
157 link_libraries(${LUA_LIBRARIES}) 178 link_libraries(${LUA_LIBRARIES})
158 endif() 179 endif()