forked from luvit/luvit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
158 lines (132 loc) · 4.63 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cmake_minimum_required(VERSION 2.8)
project (luvit C)
if(NOT DEFINED ZLIB_LIBRARIES)
find_package(ZLIB REQUIRED)
endif()
find_package(OpenSSL)
set(HAVE_OPENSSL ${OPENSSL_FOUND})
if(NOT HAVE_OPENSSL)
message(WARNING "Did not find OpenSSL")
endif()
set(HAVE_HTTP_PARSER DEFINED HTTP_PARSER_INCLUDE_DIRS)
set(HAVE_YAJL DEFINED YAJL_INCLUDE_DIRS)
set(HAVE_ODBXUV_LUA DEFINED ODBXUVLUA_INCLUDE_DIRS)
if(NOT DEFINED LUAJIT_INCLUDE_DIRS)
find_package(PkgConfig)
message(STATUS "Detecting LuaJIT...")
if(PKG_CONFIG_FOUND)
message(STATUS "Using pkg-config to detect LuaJIT...")
pkg_check_modules(LUAJIT luajit)
if(LUAJIT_FOUND)
message(STATUS "Found LuaJIT.")
message(STATUS "include: ${LUAJIT_INCLUDE_DIRS}")
include_directories(${LUAJIT_INCLUDE_DIRS})
link_directories(${LUAJIT_LIBRARY_DIRS})
set(EXTRA_LIBS ${LUAJIT_LIBRARIES})
else()
message(FATAL_ERROR "LuaJIT not found.")
endif()
else()
message(STATUS "Using local LuaJIT.")
set(LUAJIT_LIBRARIES luajit)
endif()
endif()
option(HAVE_LOCAL_LIBUV 0)
if(${HAVE_LOCAL_LIBUV})
add_subdirectory(libraries/uv)
endif()
set(LUVIT_TEMP_DIR ${CMAKE_BINARY_DIR}/luvit)
file(MAKE_DIRECTORY ${LUVIT_TEMP_DIR})
file(MAKE_DIRECTORY ${LUVIT_TEMP_DIR}/include)
file(MAKE_DIRECTORY ${LUVIT_TEMP_DIR}/include/luvit)
FILE(GLOB_RECURSE HEADER_FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/*.h")
foreach(HEADER_FILE ${HEADER_FILES})
FILE(COPY "${HEADER_FILE}" DESTINATION "${LUVIT_TEMP_DIR}/include/luvit/")
endforeach()
set(LUVIT_INCLUDE_DIRS
${LUVIT_TEMP_DIR}/include
${HTTP_PARSER_INCLUDE_DIRS}
${ARES_INCLUDE_DIRS}
${UV_INCLUDE_DIRS}
${LUAJIT_INCLUDE_DIRS}
${YAJL_INCLUDE_DIRS}
CACHE INTERNAL "Luvit include directories"
)
set(LUVIT_LIBRARY luvit CACHE INTERNAL "Luvit library")
include_directories(
${LUVIT_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/src
)
set(LUVIT_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/lconstants.c
${CMAKE_CURRENT_SOURCE_DIR}/src/lenv.c
${CMAKE_CURRENT_SOURCE_DIR}/src/los.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_debug.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_dns.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_fs.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_fs_watcher.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_handle.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luvit_exports.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luvit_init.c
# ${CMAKE_CURRENT_SOURCE_DIR}/src/luvit_main.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_misc.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_pipe.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_poll.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_process.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_stream.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_signal.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_tcp.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_timer.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_tty.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_udp.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_zlib.c
${CMAKE_CURRENT_SOURCE_DIR}/src/utils.c)
set(DETECTED_DEPS "")
if(${HAVE_OPENSSL})
message(STATUS "luvit: detected openssl")
add_definitions(-DHAVE_OPENSSL -DUSE_OPENSSL=1 -DUSE_SYSTEM_SSL=1 -DLUVIT_TARGET_OPENSSL_VERSION_NUMBER="${OPENSSL_VERSION}")
set(LUVIT_SOURCES
${LUVIT_SOURCES}
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_tls.c
${CMAKE_CURRENT_SOURCE_DIR}/src/luv_tls_conn.c)
set(DETECTED_DEPS
${DETECTED_DEPS}
${OPENSSL_LIBRARIES})
endif()
if(${HAVE_HTTP_PARSER})
message(STATUS "luvit: detected http-parser")
add_definitions(-DHAVE_HTTP_PARSER)
set(LUVIT_SOURCES ${LUVIT_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/lhttp_parser.c)
set(DETECTED_DEPS
${DETECTED_DEPS}
${HTTP_PARSER_LIBRARIES})
endif()
if(${HAVE_YAJL})
message(STATUS "luvit: detected YAJL")
add_definitions(-DHAVE_YAJL)
set(LUVIT_SOURCES ${LUVIT_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/lyajl.c)
set(DETECTED_DEPS
${DETECTED_DEPS}
${YAJL_LIBRARIES})
endif()
if(${HAVE_ODBXUV_LUA})
message(STATUS "luvit: detected ODBX-uv-lua")
add_definitions(-DHAVE_ODBXUV_LUA)
set(DETECTED_DEPS
${DETECTED_DEPS}
${ODBXUVLUA_LIBRARIES})
endif()
add_library(${LUVIT_LIBRARY} STATIC ${LUVIT_SOURCES})
target_link_libraries(${LUVIT_LIBRARY}
${UV_LIBRARIES}
${ZLIB_LIBRARIES}
${DETECTED_DEPS})
set(LUVIT_LIBRARIES
${LUVIT_LIBRARY}
CACHE INTERNAL "Luvit libraries")
if(DEFINED INSTALL_LUA_DIR)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/lib/luvit
DESTINATION ${INSTALL_LUA_DIR}
PATTERN "*")
endif()