-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
59 lines (45 loc) · 1.69 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
cmake_minimum_required(VERSION 3.8)
project(io2)
include(CheckIncludeFileCXX)
check_include_file_cxx ("experimental/filesystem" HAVE_FILESYSTEM_H)
if (CMAKE_CXX_COMPILE_FEATURES MATCHES cxx_std_17 AND HAVE_FILESYSTEM_H)
set(CMAKE_CXX_STANDARD 17)
add_definitions(-DHAVE_FILESYSTEM)
else()
set(CMAKE_CXX_STANDARD 14)
#set(Boost_USE_STATIC_LIBS ON)
find_package(Boost REQUIRED)
find_package(Boost COMPONENTS system filesystem REQUIRED)
endif()
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
find_package(LuaJit)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
include_directories("." SYSTEM
"${PROJECT_BINARY_DIR}"
"${CMAKE_SOURCE_DIR}/sol2"
${LuaJit_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
)
set(SOURCE_FILES library.cpp library.h)
add_library(io2 SHARED ${SOURCE_FILES})
include(GenerateExportHeader)
generate_export_header(io2)
set_target_properties(io2 PROPERTIES PREFIX "")
target_link_libraries(io2 ${LuaJit_LIBRARY} ${Boost_LIBRARIES})
if (NOT MSVC AND CMAKE_CXX_COMPILE_FEATURES MATCHES cxx_std_17)
target_link_libraries(io2 stdc++fs)
endif()
add_custom_target(BasicTest
DEPENDS io2
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests"
COMMAND ${CMAKE_COMMAND} -E env LUA_CPATH="${CMAKE_BINARY_DIR}/?.so\;${CMAKE_BINARY_DIR}/?.dll"
lua "${CMAKE_SOURCE_DIR}/tests/basic.lua"
)
add_custom_target(Example
DEPENDS io2
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests"
COMMAND ${CMAKE_COMMAND} -E env LUA_CPATH="${CMAKE_BINARY_DIR}/?.so\;${CMAKE_BINARY_DIR}/?.dll"
lua "${CMAKE_SOURCE_DIR}/tests/example.lua"
)