forked from TarsCloud/TarsCpp
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
executable file
·100 lines (73 loc) · 2.42 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
89
90
91
92
93
94
95
96
97
98
99
100
cmake_minimum_required(VERSION 3.10)
project(tars-cpp)
#-------------------------------------------------------------------
if("${TARS_CPP_COMMON}" STREQUAL "")
set(TARS_CPP_COMMON "1")
include("${PROJECT_SOURCE_DIR}/cmake/GenVersion.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/Common.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/BuildTarsCpp.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/Thirdparty.cmake")
include("${PROJECT_SOURCE_DIR}/cmake/ParseAsm.cmake")
endif()
include(FetchContent)
if (NOT DEFINED URL_BASE)
set(URL_BASE "github.com")
# set(URL_BASE "github.com.cnpmjs.org")
endif()
set(TARS_PROTOCOL tarsprotocol)
set(TARS_PROTOCOL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/servant/protocol)
FetchContent_Declare(${TARS_PROTOCOL}
GIT_REPOSITORY https://${URL_BASE}/FISCO-BCOS/TarsProtocol.git
GIT_TAG a5b27e917ad7633bcae241282d3396b47a700159
SOURCE_DIR ${TARS_PROTOCOL_PATH}
)
FetchContent_MakeAvailable(${TARS_PROTOCOL})
# set(major "")
# set(minor "")
# set(patch "")
# get_version(major minor patch)
# set(TARS_VERSION ${major}.${minor}.${patch})
add_definitions(-DTARS_VERSION="${TARS_VERSION}")
message("TARS_VERSION: ${TARS_VERSION}")
set(CLEAR_INCLUDE "clear-install.cmake")
FILE(WRITE ${CLEAR_INCLUDE} "EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_INSTALL_PREFIX}/include)\n")
install(SCRIPT ${CLEAR_INCLUDE})
#-------------------------------------------------------------------
include_directories(${PROJECT_SOURCE_DIR}/util/include)
include_directories(${PROJECT_SOURCE_DIR}/servant)
include_directories(${PROJECT_SOURCE_DIR}/servant/protocol)
IF(WIN32)
include_directories(${PROJECT_SOURCE_DIR}/util/src/epoll_windows)
ENDIF()
add_subdirectory(util)
add_subdirectory(tools)
add_subdirectory(servant)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_SOURCE_DIR}/cmake/tarscpp-config.cmake.in"
"${CMAKE_BINARY_DIR}/tarscpp-config.cmake"
INSTALL_DESTINATION "share/tarscpp"
)
install(
FILES "${CMAKE_BINARY_DIR}/tarscpp-config.cmake"
DESTINATION "share/tarscpp"
)
install(
EXPORT tarsutil-targets
DESTINATION share/tarscpp
NAMESPACE tarscpp::
)
install(
EXPORT tarsparse-targets
DESTINATION share/tarscpp
NAMESPACE tarscpp::
)
install(
EXPORT tarsservant-targets
DESTINATION share/tarscpp
NAMESPACE tarscpp::
)
if (TESTS)
add_subdirectory(examples)
add_subdirectory(unit-test)
endif()