annotate Resources/CMake/LuaConfiguration.cmake @ 3103:81b58b549845

back to using 'var' instead of 'let' since let is not supported by many old browsers. All variables declaration have been moved to the top of the function to better show that their scope is the function
author Alain Mazy <alain@mazy.be>
date Thu, 10 Jan 2019 10:51:36 +0100
parents 11f8d72f366f
children 0c2a8d5e0097
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
1 if (STATIC_BUILD OR NOT USE_SYSTEM_LUA)
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
2 SET(LUA_SOURCES_DIR ${CMAKE_BINARY_DIR}/lua-5.3.5)
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
3 SET(LUA_MD5 "4f4b4f323fd3514a68e0ab3da8ce3455")
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
4 SET(LUA_URL "http://www.orthanc-server.com/downloads/third-party/lua-5.3.5.tar.gz")
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1487
diff changeset
5
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1487
diff changeset
6 DownloadPackage(${LUA_MD5} ${LUA_URL} "${LUA_SOURCES_DIR}")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
7
2478
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
8 if (ENABLE_LUA_MODULES)
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
9 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
10 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD" OR
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
11 ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
12 ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
13 # Enable loading of shared libraries (for UNIX-like)
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
14 add_definitions(-DLUA_USE_DLOPEN=1)
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
15
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
16 # Publish the functions of the Lua engine (that are built within
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
17 # the Orthanc binary) as global symbols, so that the external
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
18 # shared libraries can call them
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
19 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--export-dynamic")
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
20
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
21 if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
22 ${CMAKE_SYSTEM_NAME} STREQUAL "kFreeBSD")
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
23 add_definitions(-DLUA_USE_LINUX=1)
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
24 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
25 add_definitions(
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
26 -DLUA_USE_LINUX=1
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
27 -DLUA_USE_READLINE=1
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
28 )
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
29 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
30 add_definitions(-DLUA_USE_POSIX=1)
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
31 endif()
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
32
2478
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
33 elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
34 add_definitions(
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
35 -DLUA_DL_DLL=1 # Enable loading of shared libraries (for Microsoft Windows)
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
36 )
2478
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
37
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
38 elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
39 add_definitions(
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
40 -DLUA_USE_MACOSX=1
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
41 -DLUA_DL_DYLD=1 # Enable loading of shared libraries (for Apple OS X)
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
42 )
2478
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
43
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
44 else()
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
45 message(FATAL_ERROR "Support your platform here")
1e2d5e14b3d3 New CMake option: ENABLE_LUA_MODULES to enable Lua modules
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2477
diff changeset
46 endif()
2477
amazy
parents: 2476
diff changeset
47 endif()
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
48
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
49 add_definitions(
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
50 -DLUA_COMPAT_5_2=1
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
51 )
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
52
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
53 include_directories(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
54 ${LUA_SOURCES_DIR}/src
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
55 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
56
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
57 set(LUA_SOURCES
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
58 # Don't compile the Lua command-line
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
59 #${LUA_SOURCES_DIR}/src/lua.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
60 #${LUA_SOURCES_DIR}/src/luac.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
61
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
62 # Core Lua
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
63 ${LUA_SOURCES_DIR}/src/lapi.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
64 ${LUA_SOURCES_DIR}/src/lcode.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
65 ${LUA_SOURCES_DIR}/src/lctype.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
66 ${LUA_SOURCES_DIR}/src/ldebug.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
67 ${LUA_SOURCES_DIR}/src/ldo.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
68 ${LUA_SOURCES_DIR}/src/ldump.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
69 ${LUA_SOURCES_DIR}/src/lfunc.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
70 ${LUA_SOURCES_DIR}/src/lgc.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
71 ${LUA_SOURCES_DIR}/src/llex.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
72 ${LUA_SOURCES_DIR}/src/lmem.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
73 ${LUA_SOURCES_DIR}/src/lobject.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
74 ${LUA_SOURCES_DIR}/src/lopcodes.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
75 ${LUA_SOURCES_DIR}/src/lparser.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
76 ${LUA_SOURCES_DIR}/src/lstate.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
77 ${LUA_SOURCES_DIR}/src/lstring.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
78 ${LUA_SOURCES_DIR}/src/ltable.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
79 ${LUA_SOURCES_DIR}/src/ltm.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
80 ${LUA_SOURCES_DIR}/src/lundump.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
81 ${LUA_SOURCES_DIR}/src/lvm.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
82 ${LUA_SOURCES_DIR}/src/lzio.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
83
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
84 # Base Lua modules
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
85 ${LUA_SOURCES_DIR}/src/lauxlib.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
86 ${LUA_SOURCES_DIR}/src/lbaselib.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
87 ${LUA_SOURCES_DIR}/src/lbitlib.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
88 ${LUA_SOURCES_DIR}/src/lcorolib.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
89 ${LUA_SOURCES_DIR}/src/ldblib.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
90 ${LUA_SOURCES_DIR}/src/liolib.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
91 ${LUA_SOURCES_DIR}/src/lmathlib.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
92 ${LUA_SOURCES_DIR}/src/loadlib.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
93 ${LUA_SOURCES_DIR}/src/loslib.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
94 ${LUA_SOURCES_DIR}/src/lstrlib.c
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
95 ${LUA_SOURCES_DIR}/src/ltablib.c
2947
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
96 ${LUA_SOURCES_DIR}/src/lutf8lib.c
11f8d72f366f Lua 5.3.5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2478
diff changeset
97
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
98 ${LUA_SOURCES_DIR}/src/linit.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
99 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
100
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
101 source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
102
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
103 else()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
104 include(FindLua51)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
105
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
106 if (NOT LUA51_FOUND)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
107 message(FATAL_ERROR "Please install the liblua-dev package")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
108 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
109
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
110 include_directories(${LUA_INCLUDE_DIR})
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
111 link_libraries(${LUA_LIBRARIES})
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
112 endif()