mirror of
https://github.com/skywind3000/kcp.git
synced 2024-12-25 22:50:09 +08:00
commit
f482028f24
@ -1,21 +1,49 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
||||
|
||||
project(kcp LANGUAGES C)
|
||||
|
||||
include(CTest)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
add_library(kcp STATIC ikcp.c)
|
||||
add_library(kcp_shared SHARED ikcp.c)
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
set_property(TARGET kcp_shared PROPERTY LIBRARY_OUTPUT_NAME kcp)
|
||||
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
|
||||
")
|
||||
|
||||
install(FILES ikcp.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
||||
file(WRITE "${exports_def_file}" "${exports_def_contents}")
|
||||
add_library(kcp ikcp.c "${exports_def_file}")
|
||||
else()
|
||||
add_library(kcp ikcp.c)
|
||||
endif()
|
||||
|
||||
install(TARGETS kcp_shared
|
||||
install(FILES ikcp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
install(TARGETS kcp
|
||||
EXPORT kcp-targets
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
install(EXPORT kcp-targets
|
||||
@ -24,11 +52,11 @@ install(EXPORT kcp-targets
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kcp
|
||||
)
|
||||
|
||||
if (BUILD_TESTING)
|
||||
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 ()
|
||||
endif()
|
||||
|
Loading…
Reference in New Issue
Block a user