-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
71 lines (59 loc) · 1.8 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
cmake_minimum_required(VERSION 3.1.0)
project(luasocket)
if(WIN32)
set ("LUASOCKET_SOCKET" luasocket/src/wsocket.c)
endif()
if(UNIX OR ANDROID)
set ("LUASOCKET_SOCKET"
luasocket/src/usocket.c
luasocket/src/serial.c
luasocket/src/unix.c
luasocket/src/unixdgram.c
luasocket/src/unixstream.c)
endif()
file(GLOB LUA_LIBS "luasocket/src/*.lua")
foreach(path ${LUA_LIBS})
#Get exact filename for code generation
get_filename_component(LUAFILENAME path NAME)
# Read the file and turn the bytes into comma-separated hex literals
file(READ ${path} data HEX)
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," data ${data})
# Generate the output filename by adding .h to the input filename
string(CONCAT output ${path} ".h")
#Write bin2c-like header
file(WRITE ${output} "{\nstatic const unsigned char B1[] = {${data}};\n\nif (luaL_loadbuffer(L,(const char*)B1,sizeof(B1),\"${LUAFILENAME}\")==0) lua_call(L, 0, LUA_MULTRET);\n}")
endforeach()
add_library(socket SHARED
luasocket.c
luasocket/src/auxiliar.c
luasocket/src/buffer.c
luasocket/src/compat.c
luasocket/src/except.c
luasocket/src/inet.c
luasocket/src/io.c
luasocket/src/luasocket.c
luasocket/src/options.c
luasocket/src/select.c
luasocket/src/tcp.c
luasocket/src/udp.c
luasocket/src/timeout.c
${LUASOCKET_SOCKET} )
add_library(mime SHARED
luasocket/src/compat.c
mime.c
luasocket/src/mime.c)
add_library(ltn12 SHARED
ltn12.c
)
if (WIN32)
if (MSVC)
target_link_libraries(socket wsock32 ws2_32)
else()
target_link_libraries(socket -lws2_32)
endif()
endif()
set_target_properties(socket PROPERTIES PREFIX "")
set_target_properties(mime PROPERTIES PREFIX "")
set_target_properties(ltn12 PROPERTIES PREFIX "")
set_target_properties(socket PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
set_target_properties(socket PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS TRUE)