-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
130 lines (113 loc) · 3.54 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
cmake_minimum_required(VERSION 3.21)
project(zaf VERSION 0.1.0 DESCRIPTION "ZMQ-based Actor Framework")
if (POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif ()
if (NOT DEFINED ENABLE_TEST)
set(ENABLE_TEST ON)
endif ()
message("-- ENABLE_TEST: " ${ENABLE_TEST})
if (NOT DEFINED ENABLE_PHMAP)
set(ENABLE_PHMAP ON)
endif ()
message("-- ENABLE_PHMAP: " ${ENABLE_PHMAP})
if (NOT DEFINED ENABLE_TCMALLOC)
if (APPLE)
set(ENABLE_TCMALLOC OFF)
else ()
set(ENABLE_TCMALLOC ON)
endif ()
endif ()
message("-- ENABLE_TCMALLOC: " ${ENABLE_TCMALLOC})
if (APPLE)
set(BasicLibs pthread)
else ()
set(BasicLibs pthread rt)
endif ()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
if (DEFINED ENV{ZMQ_ROOT})
set(ZMQ_ROOT_DIR $ENV{ZMQ_ROOT})
endif ()
find_package(ZMQ REQUIRED)
include_directories(${ZMQ_INCLUDE_DIR})
set(BasicLibs ${BasicLibs} ${ZMQ_LIBRARY})
set(ZAFDepsHeaders "${ZAFDepsHeaders};${ZMQ_INCLUDE_DIR}")
set(ZAFDepsSources "${ZAFDepsSources};${ZMQ_LIBRARY}")
# http://rpg.ifi.uzh.ch/docs/glog.html
if (DEFINED ENV{GLOG_ROOT})
set(GLOG_ROOT $ENV{GLOG_ROOT})
endif ()
find_package(GLOG REQUIRED)
include_directories(${GLOG_INCLUDE_DIR})
if (NOT CMAKE_BUILD_TYPE EQUAL "Debug")
add_definitions(-DNDEBUG)
endif ()
set(BasicLibs ${BasicLibs} ${GLOG_LIBRARY})
set(ZAFDepsHeaders "${ZAFDepsHeaders};${GLOG_INCLUDE_DIR}")
set(ZAFDepsSources "${ZAFDepsSources};${GLOG_LIBRARY}")
#set(CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=address -fno-omit-frame-pointer")
if (${ENABLE_PHMAP})
add_definitions(-DENABLE_PHMAP=1)
if (DEFINED ENV{PHMAP_ROOT})
set(PHMAP_ROOT $ENV{PHMAP_ROOT})
endif ()
find_package(PHMAP)
include_directories(${PHMAP_ROOT_DIR})
set(ZAFDepsHeaders "${ZAFDepsHeaders};${PHMAP_ROOT_DIR}")
endif ()
if (${ENABLE_TCMALLOC})
if (DEFINED ENV{GPERF_ROOT})
set(GPERF_ROOT $ENV{GPERF_ROOT})
endif ()
find_package(Gperftools)
include_directories(${Gperftools_INCLUDE_DIRS})
set(BasicLibs ${BasicLibs} ${Gperftools_PROFILER} ${Gperftools_TCMALLOC})
set(ZAFDepsHeaders "${ZAFDepsHeaders};${Gperftools_INCLUDE_DIRS}")
set(ZAFDepsSources "${ZAFDepsSources};${Gperftools_PROFILER};${Gperftools_TCMALLOC}")
endif ()
add_subdirectory(core)
if (${ENABLE_TEST})
if (DEFINED ENV{GTEST_ROOT})
set(GTEST_ROOT $ENV{GTEST_ROOT})
endif ()
find_package(GTest)
include_directories(${GTEST_INCLUDE_DIR})
set(TestLibs ${GTEST_LIBRARY})
add_subdirectory(tests)
endif ()
add_subdirectory(examples)
file(WRITE ${CMAKE_BINARY_DIR}/zaf_dependencies
"${ZAFDepsHeaders}\n"
"${ZAFDepsSources}\n"
"${ENABLE_PHMAP}\n"
"${ENABLE_TCMALLOC}\n"
)
# make install
include_directories(core)
add_library(zaf_static STATIC $<TARGET_OBJECTS:CoreObject>)
add_library(zaf_shared SHARED $<TARGET_OBJECTS:CoreObject>)
set_target_properties(zaf_static PROPERTIES
OUTPUT_NAME zaf
VERSION ${PROJECT_VERSION})
set_target_properties(zaf_shared PROPERTIES
OUTPUT_NAME zaf
VERSION ${PROJECT_VERSION})
if (APPLE)
target_link_libraries(zaf_shared ${ZAFDepsSources})
endif ()
include(GNUInstallDirs)
install(TARGETS zaf_static
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS zaf_shared
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY core/zaf/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/zaf
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.tpp")
install(FILES ${CMAKE_BINARY_DIR}/zaf_dependencies
DESTINATION ${CMAKE_INSTALL_PREFIX})