-
Notifications
You must be signed in to change notification settings - Fork 55
/
CMakeLists.txt
150 lines (139 loc) · 4.86 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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
cmake_minimum_required(VERSION 3.6 FATAL_ERROR)
project(luasandbox-extensions LANGUAGES NONE)
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(GNUInstallDirs)
if(WIN32)
set(CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_BINDIR})
endif()
set(CMAKE_SHARED_LIBRARY_PREFIX "")
set(PACKAGE_PREFIX luasandbox)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
if(LUA51) # build against installed lua 5.1
find_package(Lua51)
set(INSTALL_MODULE_PATH ${CMAKE_INSTALL_LIBDIR}/lua)
set(INSTALL_IOMODULE_PATH ${CMAKE_INSTALL_LIBDIR}/lua)
set(INSTALL_SANDBOX_PATH ${CMAKE_INSTALL_DATAROOTDIR}/lua)
set(INSTALL_SCHEMA_PATH ${CMAKE_INSTALL_DATAROOTDIR}/lua)
set(PACKAGE_PREFIX lua51)
if(WIN32)
string(REPLACE "\\" "\\\\" TEST_MODULE_PATH "${CMAKE_BINARY_DIR}\\install\\${CMAKE_INSTALL_LIBDIR}\\${PACKAGE_PREFIX}\\?.lua")
string(REGEX REPLACE "\\.lua$" ".dll" TEST_MODULE_CPATH ${TEST_MODULE_PATH})
else()
set(TEST_MODULE_PATH "${CMAKE_BINARY_DIR}/install/${CMAKE_INSTALL_LIBDIR}/${PACKAGE_PREFIX}/?.lua")
string(REGEX REPLACE "\\.lua$" ".so" TEST_MODULE_CPATH ${TEST_MODULE_PATH})
endif()
set(TEST_MODULE_PATH "${CMAKE_SOURCE_DIR}/common/?.lua;${TEST_MODULE_PATH}")
else() # lua_sandbox build
find_package(luasandbox 1.2.1 REQUIRED CONFIG)
set(LUA_LIBRARIES ${LUASANDBOX_LIBRARIES})
set(LUA_INCLUDE_DIR ${LUASANDBOX_INCLUDE_DIR}/luasandbox)
set(INSTALL_MODULE_PATH ${CMAKE_INSTALL_LIBDIR}/luasandbox/modules)
set(INSTALL_IOMODULE_PATH ${CMAKE_INSTALL_LIBDIR}/luasandbox/io_modules)
set(INSTALL_SANDBOX_PATH ${CMAKE_INSTALL_DATAROOTDIR}/luasandbox/sandboxes)
set(INSTALL_SCHEMA_PATH ${CMAKE_INSTALL_DATAROOTDIR}/luasandbox/schemas)
add_definitions(-DLUA_SANDBOX)
if(WIN32)
string(REPLACE "\\" "\\\\" TEST_MODULE_PATH "${CMAKE_BINARY_DIR}\\install\\${CMAKE_INSTALL_LIBDIR}\\${PACKAGE_PREFIX}\\modules\\?.lua")
string(REGEX REPLACE "\\.lua$" ".dll" TEST_MODULE_CPATH ${TEST_MODULE_PATH})
string(REGEX REPLACE "\\modules\\\\?" "\\io_modules\\?" TEST_IOMODULE_PATH ${TEST_MODULE_PATH})
string(REGEX REPLACE "\\.lua$" ".dll" TEST_IOMODULE_CPATH ${TEST_IOMODULE_PATH})
else()
set(TEST_MODULE_PATH "${CMAKE_BINARY_DIR}/install/${CMAKE_INSTALL_LIBDIR}/${PACKAGE_PREFIX}/modules/?.lua")
string(REGEX REPLACE "\\.lua$" ".so" TEST_MODULE_CPATH ${TEST_MODULE_PATH})
string(REGEX REPLACE "/modules/\\?" "/io_modules/?" TEST_IOMODULE_PATH ${TEST_MODULE_PATH})
string(REGEX REPLACE "\\.lua$" ".so" TEST_IOMODULE_CPATH ${TEST_IOMODULE_PATH})
endif()
set(TEST_MODULE_PATH "${CMAKE_SOURCE_DIR}/common/?.lua;${TEST_MODULE_PATH}")
configure_file(${CMAKE_SOURCE_DIR}/cmake/test_module.in.h ${CMAKE_BINARY_DIR}/test_module.h)
endif()
include(CTest)
configure_file(${CMAKE_SOURCE_DIR}/cmake/CTestCustom.in.cmake ${CMAKE_BINARY_DIR}/CTestCustom.cmake)
include(ExternalProject)
set(EP_CMAKE_ARGS
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/install
-DINSTALL_MODULE_PATH=${INSTALL_MODULE_PATH}
-DINSTALL_IOMODULE_PATH=${INSTALL_IOMODULE_PATH}
-DINSTALL_SANDBOX_PATH=${INSTALL_SANDBOX_PATH}
-DLUA51=${LUA51}
--no-warn-unused-cli)
set(extensions
amqp
aws
bit
bloom_filter
circular_buffer
cjson
compat
cuckoo_filter
elasticsearch
gcp
# geoip # deprecated use maxminddb
gzfile
hindsight
heka
hyperloglog
irc
jose
kafka
libinjection
lfs
lpeg
lsb
lyaml
maxminddb
# moz_ingest deprecated
# moz_logging deprecated
# moz_pioneer deprecated
# moz_security deprecated
# moz_telemetry deprecated
openssl
papertrail
parquet
postgres
rjson
sax
# snappy # deprecated
socket
ssl
struct
syslog
systemd
taskcluster
xxhash
zlib
)
foreach(ext IN LISTS extensions)
if(ENABLE_ALL_EXT)
option(EXT_${ext} "include extension ${ext}" ON)
else()
option(EXT_${ext} "include extension ${ext}" OFF)
endif()
endforeach()
if(NOT CPACK_GENERATOR)
if(WIN32)
set(CPACK_GENERATOR ZIP)
else()
set(CPACK_GENERATOR TGZ)
endif()
endif()
set(PACKAGE_COMMANDS "")
foreach(ext IN LISTS extensions)
if (EXT_${ext})
add_subdirectory(${ext})
set(PACKAGE_COMMANDS ${PACKAGE_COMMANDS} COMMAND cpack -G ${CPACK_GENERATOR} --config ${ext}.cpack)
message("${ext}\tENABLED")
else()
message("${ext}\tDISABLED")
endif()
endforeach()
if(PACKAGE_COMMANDS STREQUAL "")
message(FATAL_ERROR "No extensions were specificed use -DENABLE_ALL_EXT=true or specify any of the following -DEXT_[${extensions}]=on ...")
endif()
add_custom_target(packages ${PACKAGE_COMMANDS})
add_custom_target(docs lua gen_gh_pages.lua "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})