-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
81 lines (65 loc) · 2.13 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(lua)
set(TO_INC lua.h luaconf.h lualib.h lauxlib.h lua.hpp)
set(INSTALL_BIN bin)
set(INSTALL_INC include)
set(INSTALL_LIB lib)
INCLUDE_DIRECTORIES(
src
)
AUX_SOURCE_DIRECTORY(src SRC_LIST)
list(REMOVE_ITEM SRC_LIST src/lua.c src/luac.c)
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
if (ANDROID)
add_definitions(-D\"lua_getlocaledecpoint\(\)='.'\")
endif()
if (NOT ANDROID)
ADD_EXECUTABLE(lua src/lua.c ${SRC_LIST})
ADD_EXECUTABLE(luac src/luac.c ${SRC_LIST})
endif()
if (NOT ANDROID AND UNIX )
TARGET_LINK_LIBRARIES(lua m)
TARGET_LINK_LIBRARIES(luac m)
endif()
if (MSVC)
add_definitions(-DLUA_BUILD_AS_DLL)
endif()
if (MSVC)
set(STATIC_LIB_NAME liblua_a)
set(SHARED_LIB_NAME liblua)
else (MSVC)
set(STATIC_LIB_NAME lua_static)
set(SHARED_LIB_NAME lua_shared)
endif()
ADD_LIBRARY(${STATIC_LIB_NAME} STATIC ${SRC_LIST})
if (NOT MSVC)
SET_TARGET_PROPERTIES(${STATIC_LIB_NAME} PROPERTIES OUTPUT_NAME "lua")
SET_TARGET_PROPERTIES(${STATIC_LIB_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
if (MSVC OR (NOT ANDROID AND UNIX) OR (NOT ANDROID AND APPLE))
ADD_LIBRARY(${SHARED_LIB_NAME} SHARED ${SRC_LIST})
if (NOT MSVC)
SET_TARGET_PROPERTIES(${SHARED_LIB_NAME} PROPERTIES OUTPUT_NAME "lua")
SET_TARGET_PROPERTIES(${SHARED_LIB_NAME} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
endif()
FOREACH(FILE ${TO_INC})
INSTALL(FILES src/${FILE} DESTINATION ${INSTALL_INC})
ENDFOREACH(FILE)
INSTALL(TARGETS ${STATIC_LIB_NAME} ARCHIVE DESTINATION ${INSTALL_LIB})
if ((NOT ANDROID AND UNIX) OR (NOT ANDROID AND APPLE))
INSTALL(TARGETS lua luac ${SHARED_LIB_NAME}
RUNTIME DESTINATION ${INSTALL_BIN}
LIBRARY DESTINATION ${INSTALL_LIB}
ARCHIVE DESTINATION ${INSTALL_LIB}
)
endif()
if (MSVC)
INSTALL(TARGETS lua luac RUNTIME DESTINATION ${INSTALL_BIN})
INSTALL(TARGETS ${SHARED_LIB_NAME}
RUNTIME DESTINATION ${INSTALL_LIB}
LIBRARY DESTINATION ${INSTALL_LIB}
ARCHIVE DESTINATION ${INSTALL_LIB}
)
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
endif()