This repository has been archived by the owner on Nov 20, 2020. It is now read-only.
forked from lunarmodules/luasocket
-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
79 lines (69 loc) · 2.74 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
72
73
74
75
76
77
78
79
# Copyright (C) 2007-2012 LuaDist.
# Created by Peter Drahoš, David Manura
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Please note that the package source code is licensed under its own license.
project ( luasocket C )
cmake_minimum_required ( VERSION 2.8 )
include ( cmake/dist.cmake )
include ( lua )
# The standard luasocket build has this enabled in release mode.
# It is required for running the test suite.
add_definitions ( -DLUASOCKET_DEBUG )
# Shared library exporting.
if ( WIN32 )
add_definitions ( "-DMIME_API=__declspec(dllexport)" "-DLUASOCKET_API=__declspec(dllexport)" )
endif ( )
if ( WIN32 AND NOT CYGWIN )
set ( SOCKETC src/wsocket.c )
else ( )
set ( SOCKETC src/usocket.c )
endif ( )
set ( SRC_SOCKET src/luasocket.c src/timeout.c src/buffer.c src/io.c src/auxiliar.c
src/options.c src/inet.c src/tcp.c src/udp.c src/except.c src/select.c ${SOCKETC} )
if ( WIN32 AND NOT CYGWIN )
set ( LIB_SOCKET ws2_32 )
endif ( )
# Binary
install_lua_module ( socket.core ${SRC_SOCKET} LINK ${LIB_SOCKET} )
install_lua_module ( mime.core src/mime.c )
# Lua
install_lua_module ( ltn12 src/ltn12.lua )
install_lua_module ( mime src/mime.lua )
install_lua_module ( socket src/socket.lua )
install_lua_module ( socket.ftp src/ftp.lua )
install_lua_module ( socket.headers src/headers.lua )
install_lua_module ( socket.http src/http.lua )
install_lua_module ( socket.smtp src/smtp.lua )
install_lua_module ( socket.tp src/tp.lua )
install_lua_module ( socket.url src/url.lua )
install_foo ( etc/ )
install_test ( test/ )
install_example ( samples/ )
install_doc ( doc/ )
install_data ( README NEW LICENSE )
# very basic test
file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/t/t.lua " require 'socket' " )
add_lua_test ( ${CMAKE_CURRENT_BINARY_DIR}/t/t.lua )
# test with client-server.
# This is more complicated because the test suite client and server must be
# run in different threads (or different processes).
find_package ( Threads )
if ( Threads_FOUND )
add_lua_module ( testing_thread test/testing_thread.c LINK ${CMAKE_THREAD_LIBS_INIT} )
file ( WRITE ${CMAKE_CURRENT_BINARY_DIR}/t/clientserver.lua "
local socket = require 'socket'
function sleep(sec) socket.select(nil, nil, sec) end
print('RUN_THREAD=', RUN_THREAD)
if RUN_THREAD then
dofile '${CMAKE_CURRENT_SOURCE_DIR}/test/testsrvr.lua'
else
require 'testing_thread' '${CMAKE_CURRENT_BINARY_DIR}/clientserver.lua'
sleep(2) -- allow some time for server to start
dofile '${CMAKE_CURRENT_SOURCE_DIR}/test/testclnt.lua'
end
" )
add_lua_test ( ${CMAKE_CURRENT_BINARY_DIR}/t/clientserver.lua )
else ()
message ( WARNING "skipping tests (no threading)" )
endif ()