forked from xjdrew/levent
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
60 lines (53 loc) · 1.92 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
cmake_minimum_required (VERSION 2.8)
project(Levent)
set(levent_cmake "config.cmake")
if (EXISTS $ENV{LEVENT_CMAKE})
set(levent_cmake $ENV{LEVENT_CMAKE})
endif()
include(${levent_cmake})
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb")
#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -save-temps")
#message("name:${CMAKE_SYSTEM_NAME}")
#message("linker flags:${CMAKE_SHARED_LINKER_FLAGS}")
#message("compiler: ${CMAKE_C_COMPILER}")
include_directories(${LUA_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/deps/http-parser)
include_directories(${LUA_INCLUDE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/deps/libev)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/deps/libev/.libs/)
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup")
endif()
add_definitions(-DHTTP_PARSER_STRICT=0)
if(WIN32)
set(suffix ".dll")
add_definitions(-DLUA_BUILD_AS_DLL -DLUA_LIB -DHTTP_PARSER_STRICT=0)
else()
set(suffix ".so")
endif()
macro (add_lua_library lname)
add_library(${lname} SHARED ${ARGN})
if(WIN32)
target_link_libraries(${lname} ${LUA_LIBRARIES})
endif()
set_target_properties(${lname} PROPERTIES PREFIX "")
set_target_properties(${lname} PROPERTIES SUFFIX ${suffix})
endmacro()
# levent.module
set(CSOURCE src/lua-socket.c src/lua-errno.c src/lua-levent.c src/lua-ev.c src/lua-http-parser.c deps/http-parser/http_parser.c)
set(CMONGO ext/mongo/lua-mongo.c)
set(CBSON ext/mongo/lua-bson.c)
IF(NOT WIN32)
add_lua_library(levent ${CSOURCE})
target_link_libraries(levent ev)
add_custom_command(TARGET levent
PRE_BUILD
COMMAND CFLAGS=-fPIC ./configure --enable-shared=no
COMMAND make
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/deps/libev)
add_lua_library(mongo ${CMONGO})
add_lua_library(bson ${CBSON})
ELSE()
set(CSOURCE ${CSOURCE} src/evwrap.c)
add_lua_library(levent ${CSOURCE})
add_lua_library(mongo ${CMONGO})
add_lua_library(bson ${CBSON})
ENDIF()