mirror of
https://github.com/skywind3000/kcp.git
synced 2024-12-25 22:50:09 +08:00
simplify
This commit is contained in:
parent
6900c9128e
commit
3c9fd966f9
@ -1,21 +1,13 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12)
|
||||
|
||||
if(DEFINED PROJECT_NAME)
|
||||
set(KCP_IS_TOP_PROJECT OFF)
|
||||
else()
|
||||
set(KCP_IS_TOP_PROJECT ON)
|
||||
endif()
|
||||
|
||||
project(kcp LANGUAGES C)
|
||||
|
||||
include(CTest)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
cmake_policy(SET CMP0054 NEW)
|
||||
|
||||
option(KCP_BUILD_SHARED_LIBS "Build KCP as a shared lib" OFF)
|
||||
option(KCP_BUILD_INSTALL "Build install target" ${KCP_IS_TOP_PROJECT})
|
||||
option(KCP_BUILD_TESTS "Build tests" ${KCP_IS_TOP_PROJECT})
|
||||
|
||||
if(KCP_BUILD_SHARED_LIBS)
|
||||
if(WIN32)
|
||||
if(BUILD_SHARED_LIBS AND WIN32)
|
||||
set(exports_def_file "${CMAKE_CURRENT_BINARY_DIR}/exports.def")
|
||||
set(exports_def_contents
|
||||
"EXPORTS
|
||||
@ -39,36 +31,28 @@ if(KCP_BUILD_SHARED_LIBS)
|
||||
")
|
||||
|
||||
file(WRITE "${exports_def_file}" "${exports_def_contents}")
|
||||
add_library(kcp SHARED ikcp.h ikcp.c "${exports_def_file}")
|
||||
else()
|
||||
add_library(kcp SHARED ikcp.h ikcp.c)
|
||||
endif()
|
||||
add_library(kcp ikcp.c "${exports_def_file}")
|
||||
else()
|
||||
add_library(kcp STATIC ikcp.h ikcp.c)
|
||||
add_library(kcp ikcp.c)
|
||||
endif()
|
||||
|
||||
if(KCP_BUILD_INSTALL)
|
||||
include(GNUInstallDirs)
|
||||
install(FILES ikcp.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
|
||||
set_target_properties(kcp PROPERTIES PUBLIC_HEADER ikcp.h)
|
||||
|
||||
install(TARGETS kcp
|
||||
install(TARGETS kcp
|
||||
EXPORT kcp-targets
|
||||
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
|
||||
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
|
||||
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
)
|
||||
INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
|
||||
)
|
||||
|
||||
install(EXPORT kcp-targets
|
||||
install(EXPORT kcp-targets
|
||||
FILE kcp-config.cmake
|
||||
NAMESPACE kcp::
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/kcp
|
||||
)
|
||||
endif()
|
||||
)
|
||||
|
||||
if(KCP_BUILD_TESTS)
|
||||
if(BUILD_TESTING)
|
||||
enable_language(CXX)
|
||||
|
||||
add_executable(kcp_test test.cpp)
|
||||
|
Loading…
Reference in New Issue
Block a user