-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
88 lines (79 loc) · 3.02 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
cmake_minimum_required(VERSION 2.8)
SET(LIBNAME io)
project(${LIBNAME})
# setup directory where we should look for cmake modules files
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#3rd
#include_directories(${CMAKE_SOURCE_DIR}/third_party/rapidjson/include)
#include_directories(${CMAKE_SOURCE_DIR}/third_party/spdlog-1.6.1/include)
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
set(SPDLOG_MASTER_PROJECT ON)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/rapidjson/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/spdlog/include)
message(STATUS "======== IO CURRENT ========")
else()
include_directories(${CMAKE_SOURCE_DIR}/third_party/rapidjson/include)
include_directories(${CMAKE_SOURCE_DIR}/third_party/spdlog/include)
message(STATUS "======== IO SUBDIRECTORY ========")
endif()
# threads
find_package(Threads REQUIRED)
SET(ADD_LINK_LIB_FLAGS "-Wl,--rpath=$ORIGIN../:$ORIGIN")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${ADD_LINK_LIB_FLAGS}")
IF(USE_GMTASSL)
# GMSSL
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rd/gmssl/include)
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rd/gmssl/lib)
link_libraries(tacrypto tassl)
ELSE()
# OpenSSL
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
link_libraries(${OPENSSL_LIBRARIES})
ENDIF()
############################### Begin
# libraries
file(GLOB_RECURSE srcs src/*.cpp)
add_library(${LIBNAME} SHARED ${srcs})
target_include_directories(${LIBNAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
#target_link_libraries(${LIBNAME} PUBLIC pthread)
add_dependencies(${LIBNAME} spdlog)
target_link_libraries(${LIBNAME} PUBLIC spdlog pthread)
#if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
# target_link_libraries(${LIBNAME} PUBLIC pthread)
#else()
# add_dependencies(${LIBNAME} spdlog)
# target_link_libraries(${LIBNAME} PUBLIC spdlog pthread)
#endif()
set_target_properties(${LIBNAME} PROPERTIES FOLDER "io"
APPEND_STRING PROPERTY LINK_FLAGS " ${ADD_LINK_LIB_FLAGS}")
install(TARGETS ${LIBNAME} DESTINATION lib)
install(DIRECTORY include/io DESTINATION include)
if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_SOURCE_DIR})
add_subdirectory(third_party/spdlog)
endif()
#IF(ROSETTA_COMPILE_TESTS)
## examples
#function(compile_examples projname)
# set(proj ${LIBNAME}-examples-${projname})
# add_executable(${proj} ./examples/${projname}.cpp)
# target_link_libraries(${proj} ${LIBNAME})
#endfunction()
#compile_examples(net_broadcast)
#compile_examples(net_interactive)
#compile_examples(net_multiclients)
#compile_examples(net_sync)
#compile_examples(net_msgid)
##
#compile_examples(netio_ex)
#
## tests
#function(compile_tests projname)
# set(proj ${LIBNAME}-tests-${projname})
# add_executable(${proj} ./tests/${projname}.cpp ./tests/test.cpp)
# target_link_libraries(${proj} ${LIBNAME})
#endfunction()
#compile_tests(test_net_io)
#compile_tests(test_parallel_net_io)
################################ End
#ENDIF()