-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (116 loc) · 4.11 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
131
132
133
134
135
136
137
138
139
cmake_minimum_required(VERSION 3.12.4)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(wsong LANGUAGES C CXX)
# Version
set(libwsong_VERSION 1.0rc0)
set(libwsong_build_VERSION 1.0rc0)
# C++ STANDARD
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_C_STANDARD 11)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -Wall -ggdb -gdwarf-3 -ftemplate-backtrace-limit=0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -mprefer-vector-width=512 -Wall -fcompare-debug-second")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wall -ggdb -dgwarf-3 -O3")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -ggdb -gdwarf-3 -ftemplate-backtrace-limit=0")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -mprefer-vector-width=512 -Wall -fcompare-debug-second")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -Wall -ggdb -dgwarf-3 -O3")
# find cache size
execute_process(COMMAND getconf LEVEL1_DCACHE_LINESIZE OUTPUT_VARIABLE CLSZ)
string(STRIP ${CLSZ} CLSZ)
set(CACHELINE_SIZE ${CLSZ})
# find default page size
execute_process(COMMAND getconf PAGESIZE OUTPUT_VARIABLE PGSZ)
string(STRIP ${PGSZ} PGSZ)
set(PAGE_SIZE ${PGSZ})
include(GNUInstallDirs)
if ( NOT DEFINED CMAKE_INSTALL_LIBDIR )
set( CMAKE_INSTALL_LIBDIR lib )
endif ()
if ( NOT DEFINED CMAKE_INSTALL_INCLUDEDIR )
set( CMAKE_INSTALL_INCLUDEDIR include )
endif ( )
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules")
# doxygen
find_package(Doxygen)
# jemalloc
find_package(Jemalloc)
if (${JEMALLOC_FOUND})
message(STATUS "Jemalloc is found, shmalloc compoment is enabled.")
set(ENABLE_SHMALLOC 1)
else()
message(STATUS "Jemalloc not found, shmalloc component is disabled.")
set(ENABLE_SHMALLOC 0)
endif()
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/wsong/config.h)
add_subdirectory(src/perf)
add_subdirectory(src/ipc)
add_subdirectory(src/applications)
add_library(perf SHARED
$<TARGET_OBJECTS:perf_objs>
)
set_target_properties(perf PROPERTIES
OUTPUT_NAME wsongperf
)
add_library(ipc SHARED
$<TARGET_OBJECTS:ipc_objs>
)
if (${ENABLE_SHMALLOC})
target_link_libraries(ipc ${JEMALLOC_LIBRARIES})
endif()
set_target_properties(ipc PROPERTIES
OUTPUT_NAME wsongipc
)
# make install
install(TARGETS perf ipc EXPORT libwsongTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/include/wsong
${CMAKE_CURRENT_BINARY_DIR}/include/wsong
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libwsongConfigVersion.cmake"
VERSION ${libwsong_VERSION}
COMPATIBILITY AnyNewerVersion
)
export (EXPORT libwsongTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/libwsongTargets.cmake"
)
set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/libwsong)
configure_package_config_file(libwsongConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libwsongConfig.cmake"
INSTALL_DESTINATION ${ConfigPackageLocation}
PATH_VARS CMAKE_INSTALL_LIBDIR CMAKE_INSTALL_INCLUDEDIR
)
install(EXPORT libwsongTargets
FILE libwsongTargets.cmake
NAMESPACE libwsong::
DESTINATION ${ConfigPackageLocation}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libwsongConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libwsongConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
)
# documentation
set (DOXYGEN_EXCLUDE src/applications)
set (DOXYGEN_PROJECT_NUMBER ${libwsong_VERSION})
set (DOXYGEN_TAB_SIZE 4)
set (DOXYGEN_WARNINGS NO)
set (DOXYGEN_WARN_IF_UNDOCUMENTED NO)
set (DOXYGEN_WARN_NO_PARAMDOC NO)
if (DOXYGEN_FOUND)
# create docs
doxygen_add_docs(docs
${CMAKE_SOURCE_DIR}/README.md
${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/src
ALL
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
endif()