-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
85 lines (67 loc) · 2.45 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
cmake_minimum_required(VERSION 3.18)
project(lua-c-api-tests
LANGUAGES C CXX
VERSION "1.0.0"
)
find_program(SHELL sh)
find_program(ECHO echo)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_INCLUDE_PATH})
include(cmake/utils.cmake)
option(USE_LUA "Use PUC Rio Lua library" OFF)
option(USE_LUAJIT "Use LuaJIT library" OFF)
option(ENABLE_ASAN "Enable AddressSanitizer" OFF)
option(ENABLE_UBSAN "Enable UndefinedBehaviorSanitizer" OFF)
option(ENABLE_COV "Enable coverage instrumentation" OFF)
option(ENABLE_LUA_ASSERT "Enable all assertions inside Lua source code" ON)
option(ENABLE_LUA_APICHECK "Enable consistency checks on the C API" ON)
option(ENABLE_LUAJIT_RANDOM_RA "Enable randomness in a register allocation" OFF)
option(OSS_FUZZ "Enable support of OSS Fuzz" OFF)
option(ENABLE_BUILD_PROTOBUF "Enable building Protobuf library" ON)
option(ENABLE_BONUS_TESTS "Enable bonus tests" OFF)
option(ENABLE_INTERNAL_TESTS "Enable internal tests" OFF)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
set(CMAKE_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_INCLUDE_PATH})
include(SetBuildParallelLevel)
include(SetHardwareArch)
if (ENABLE_LUAJIT_RANDOM_RA AND NOT USE_LUAJIT)
message(FATAL_ERROR "Option ENABLE_LUAJIT_RANDOM_RA is LuaJIT-specific.")
endif (ENABLE_LUAJIT_RANDOM_RA AND NOT USE_LUAJIT)
if (USE_LUA AND NOT LUA_VERSION)
set(LUA_VERSION "master")
endif()
if (USE_LUAJIT AND NOT LUA_VERSION)
set(LUA_VERSION "v2.1")
endif()
if (USE_LUA)
include(BuildLua)
build_lua(${LUA_VERSION})
elseif (USE_LUAJIT)
include(BuildLuaJIT)
build_luajit(${LUA_VERSION})
else ()
message(FATAL_ERROR "No Lua is specified.")
endif ()
message(STATUS "Found ${LUA_VERSION_STRING}")
if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
message(FATAL_ERROR
"\n"
"Building is supported with Clang compiler only.\n"
" $ rm -rf build\n"
" $ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -S . -B build\n"
" $ cmake --build build --parallel\n"
"\n")
endif()
find_package(Protobuf)
if (NOT Protobuf_FOUND)
set(ENABLE_BUILD_PROTOBUF ON)
endif (NOT Protobuf_FOUND)
SetBuildParallelLevel(CMAKE_BUILD_PARALLEL_LEVEL)
if(ENABLE_COV)
include(CodeCoverage)
endif()
enable_testing()
add_subdirectory(extra)
add_subdirectory(libluamut)
add_subdirectory(tests)