commit
f482028f24
@ -1,21 +1,49 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
||||||
|
|
||||||
project(kcp LANGUAGES C)
|
project(kcp LANGUAGES C)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
add_library(kcp STATIC ikcp.c)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
add_library(kcp_shared SHARED ikcp.c)
|
|
||||||
|
|
||||||
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
|
EXPORT kcp-targets
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||||
|
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||||
)
|
)
|
||||||
|
|
||||||
install(EXPORT kcp-targets
|
install(EXPORT kcp-targets
|
||||||
@ -24,11 +52,11 @@ install(EXPORT kcp-targets
|
|||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kcp
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kcp
|
||||||
)
|
)
|
||||||
|
|
||||||
if (BUILD_TESTING)
|
if(BUILD_TESTING)
|
||||||
enable_language(CXX)
|
enable_language(CXX)
|
||||||
|
|
||||||
add_executable(kcp_test test.cpp)
|
add_executable(kcp_test test.cpp)
|
||||||
if(MSVC AND NOT (MSVC_VERSION LESS 1900))
|
if(MSVC AND NOT (MSVC_VERSION LESS 1900))
|
||||||
target_compile_options(kcp_test PRIVATE /utf-8)
|
target_compile_options(kcp_test PRIVATE /utf-8)
|
||||||
endif()
|
endif()
|
||||||
endif ()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user