-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
CMakeLists.txt
62 lines (52 loc) · 1.33 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
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
project(kcp LANGUAGES C)
include(CTest)
include(GNUInstallDirs)
cmake_policy(SET CMP0054 NEW)
if(BUILD_SHARED_LIBS AND WIN32)
set(exports_def_file "${CMAKE_CURRENT_BINARY_DIR}/exports.def")
set(exports_def_contents
"EXPORTS
ikcp_create
ikcp_release
ikcp_setoutput
ikcp_recv
ikcp_send
ikcp_update
ikcp_check
ikcp_input
ikcp_flush
ikcp_peeksize
ikcp_setmtu
ikcp_wndsize
ikcp_waitsnd
ikcp_nodelay
ikcp_log
ikcp_allocator
ikcp_getconv
")
file(WRITE "${exports_def_file}" "${exports_def_contents}")
add_library(kcp ikcp.c "${exports_def_file}")
else()
add_library(kcp ikcp.c)
endif()
install(FILES ikcp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(TARGETS kcp
EXPORT kcp-targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(EXPORT kcp-targets
FILE kcp-config.cmake
NAMESPACE kcp::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kcp
)
if(BUILD_TESTING)
enable_language(CXX)
add_executable(kcp_test test.cpp)
if(MSVC AND NOT (MSVC_VERSION LESS 1900))
target_compile_options(kcp_test PRIVATE /utf-8)
endif()
endif()