-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
60 lines (52 loc) · 2.42 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
# 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.0 FATAL_ERROR)
project(sax VERSION 0.5.0 LANGUAGES C)
set(CPACK_PACKAGE_NAME luasandbox-${PROJECT_NAME})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Lua SAX Module")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_PACKAGE_VENDOR "Mozilla Services")
set(CPACK_PACKAGE_CONTACT "Mike Trinkala <trink@mozilla.com>")
set(CPACK_OUTPUT_CONFIG_FILE "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.cpack")
set(CPACK_STRIP_FILES TRUE)
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
set(CPACK_RPM_FILE_NAME "RPM-DEFAULT")
set(CPACK_RPM_PACKAGE_LICENSE "MIT License")
if(MSVC)
set(CMAKE_C_FLAGS "/W3 /WX")
set(CMAKE_C_FLAGS_RELEASE "/MD /O2 /Ob2")
else()
set(CMAKE_C_FLAGS "-std=c99 -pedantic -Werror -Wall -Wextra -fPIC")
set(CMAKE_C_FLAGS_RELEASE "-O2")
set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
endif()
set(CMAKE_SHARED_LIBRARY_PREFIX "")
if(LUA51) # build against installed lua 5.1
set(CPACK_DEBIAN_PACKAGE_DEPENDS "lua5.1")
set(CPACK_PACKAGE_NAME lua51-${PROJECT_NAME})
find_package(Lua51)
find_program(LUA NAMES lua lua.bat)
add_test(NAME test COMMAND ${LUA} test.lua)
else() # lua_sandbox build
set(CPACK_DEBIAN_PACKAGE_DEPENDS "luasandbox (>= 1.0.2)")
find_package(luasandbox 1.0.2 REQUIRED CONFIG)
set(LUA_LIBRARIES ${LUASANDBOX_LIBRARIES})
set(LUA_INCLUDE_DIR ${LUASANDBOX_INCLUDE_DIR}/luasandbox)
endif()
find_library(LIBM_LIBRARY m)
include(CPack)
include_directories(${LUA_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include)
add_definitions(-DLUA_SANDBOX -DDIST_VERSION="${PROJECT_VERSION}")
add_library(sax SHARED src/symtseries.c lua/lua_sax.c lua/lua_sax.def)
target_link_libraries(sax ${LUA_LIBRARIES})
if(LIBM_LIBRARY)
target_link_libraries(sax ${LIBM_LIBRARY})
endif()
set(DPERMISSION DIRECTORY_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(EMPTY_DIR ${CMAKE_BINARY_DIR}/empty)
file(MAKE_DIRECTORY ${EMPTY_DIR})
install(DIRECTORY ${EMPTY_DIR}/ DESTINATION ${INSTALL_MODULE_PATH} ${DPERMISSION})
install(TARGETS sax DESTINATION ${INSTALL_MODULE_PATH})