-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
71 lines (51 loc) · 1.84 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
63
64
65
66
67
68
69
70
71
cmake_minimum_required (VERSION 2.8)
project (nylonsock)
option(BUILD_DEBUG "Builds using debug mode" OFF)
option(BUILD_TESTS "Build test programs" ON)
option(BUILD_STATIC "Builds a static library if enabled. Otherwise builds a shared library" OFF)
IF (BUILD_DEBUG)
set(CMAKE_BUILD_TYPE Debug)
ENDIF (BUILD_DEBUG)
IF (NOT WIN32)
set(INCLUDE_DIR ${CMAKE_BINARY_DIR}/${PROJECT_NAME})
set(LIB_DIR ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/lib)
set(TEST_DIR ${CMAKE_BINARY_DIR}/${PROJECT_NAME}/test)
file(MAKE_DIRECTORY ${INCLUDE_DIR})
file(MAKE_DIRECTORY ${LIB_DIR})
file(MAKE_DIRECTORY ${TEST_DIR})
file(COPY NylonSock/include DESTINATION ${INCLUDE_DIR})
set(EXECUTABLE_OUTPUT_PATH ${TEST_DIR})
ENDIF(NOT WIN32)
set(LIB_NAME nylonsock)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -pthread")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIB_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIB_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${TEST_DIR})
include_directories("${PROJECT_SOURCE_DIR}/NylonSock/include/")
include_directories("${PROJECT_SOURCE_DIR}/NylonSock/src/")
IF (WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
ENDIF(WIN32)
set(SRCS
NylonSock/src/Socket.cpp
)
set(INCLUDES
NylonSock/include/NylonSock.hpp
)
if (BUILD_STATIC)
add_library(${LIB_NAME} STATIC ${SRCS})
else(BUILD_STATIC)
add_library(${LIB_NAME} SHARED ${SRCS})
ENDIF (BUILD_STATIC)
IF (WIN32)
target_link_libraries(nylonsock ws2_32)
ENDIF(WIN32)
IF (BUILD_TESTS)
include_directories("${PROJECT_SOURCE_DIR}/NylonSock/test/")
add_executable(TestServer "${PROJECT_SOURCE_DIR}/NylonSock/test/testserver.cpp")
add_executable(TestClient "${PROJECT_SOURCE_DIR}/NylonSock/test/testclient.cpp")
target_link_libraries(TestServer ${LIB_NAME})
target_link_libraries(TestClient ${LIB_NAME})
ENDIF (BUILD_TESTS)
install(TARGETS ${LIB_NAME} DESTINATION lib)
install(FILES ${INCLUDES} DESTINATION include/nylonsock)