forked from pigpigyyy/Yuescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
50 lines (42 loc) · 1.79 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
project(yue CXX)
cmake_minimum_required(VERSION 3.1)
SET(LUA_LIBDIR ${LUA_INCDIR}/../lib " " ${LUA_INCDIR}/../../lib)
find_package(Lua)
IF(LUA_FOUND)
SET(LUA_LIBRARIES "${LUA_LIBRARY}")
ELSE(LUA_FOUND)
MESSAGE(STATUS "Lua: using information from luarocks")
SET(LUA_INCLUDE_DIR "${LUA_INCDIR}")
GET_FILENAME_COMPONENT(LUA_EXEC_NAME ${LUA} NAME_WE)
IF(LUA_EXEC_NAME STREQUAL "luajit")
FIND_LIBRARY(LUA_LIBRARIES
NAMES luajit libluajit
PATHS ${LUA_LIBDIR}
NO_DEFAULT_PATH)
ELSEIF(LUA_EXEC_NAME MATCHES "lua.*")
FIND_LIBRARY(LUA_LIBRARIES
NAMES lua lua54 lua53 lua52 lua51 liblua liblua54 liblua53 liblua52 liblua51 liblua5.4 liblua5.3 liblua5.2 liblua5.1
PATHS ${LUA_LIBDIR}
NO_DEFAULT_PATH)
ENDIF(LUA_EXEC_NAME STREQUAL "luajit")
ENDIF(LUA_FOUND)
MESSAGE(STATUS "Lua: " ${LUA})
MESSAGE(STATUS "Lua include: " ${LUA_INCLUDE_DIR})
MESSAGE(STATUS "Lua library: ${LUA_LIBRARIES}")
enable_language(CXX)
include_directories(src src/3rdParty ${LUA_INCLUDE_DIR})
add_definitions(-std=c++17 -O3 -fPIC)
add_library(libyue MODULE src/yuescript/ast.cpp src/yuescript/parser.cpp src/yuescript/yue_parser.cpp src/yuescript/yue_compiler.cpp src/yuescript/yuescript.cpp)
set_target_properties(libyue PROPERTIES PREFIX "")
set_target_properties(libyue PROPERTIES OUTPUT_NAME "yue")
target_link_libraries(libyue ${LUA_LIBRARIES})
find_package(Threads REQUIRED)
add_executable(yue src/yuescript/ast.cpp src/yuescript/yue_compiler.cpp src/yuescript/yue_parser.cpp src/yuescript/yuescript.cpp src/yuescript/parser.cpp src/yue.cpp)
target_link_libraries(yue ${LUA_LIBRARIES} Threads::Threads)
IF(CMAKE_DL_LIBS)
target_link_libraries(yue ${CMAKE_DL_LIBS})
ENDIF(CMAKE_DL_LIBS)
IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_link_options(yue PRIVATE -lstdc++fs)
ENDIF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
install(CODE "")