-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
171 lines (141 loc) · 4.53 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright(c) 2023 ffashion <[email protected]>
# Copyright(c) 2023 Jalen Wong <[email protected]>
#
cmake_minimum_required(VERSION 3.12)
project(bfdev VERSION 1.0.5 LANGUAGES C)
include(GNUInstallDirs)
include(CheckIncludeFiles)
set(BFDEV_NAME sirius)
set(BFDEV_VERSION ${PROJECT_VERSION})
set(BFDEV_EXTREVERSION -devel)
if(BFDEV_EXTREVERSION)
string(APPEND BFDEV_VERSION ${BFDEV_EXTREVERSION})
endif()
set(BFDEV_ARCH generic)
set(BFDEV_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(BFDEV_HEADER_PATH ${PROJECT_SOURCE_DIR}/include)
set(BFDEV_SOURCE_PATH ${PROJECT_SOURCE_DIR}/src)
set(BFDEV_DOCUMENT_PATH ${PROJECT_SOURCE_DIR}/docs)
set(BFDEV_GENERATED_PATH ${PROJECT_BINARY_DIR}/generated)
set(BFDEV_ARCH_PATH ${PROJECT_SOURCE_DIR}/arch/${BFDEV_ARCH})
set(BFDEV_ARCH_HEADER_PATH ${BFDEV_ARCH_PATH}/include)
set(BFDEV_CONFIGURE ${BFDEV_GENERATED_PATH}/bfdev-config.cmake)
include(scripts/hostrule.cmake)
include(scripts/packed-header.cmake)
include(scripts/commit.cmake)
commit_hash(BFDEV_COMMITID)
commit_branch(BFDEV_BRANCH)
string(TIMESTAMP BFDEV_BUILD_TIME "%A %B %d %H:%M:%S UTC %Y" UTC)
string(APPEND BFDEV_RELEASE
"${PROJECT_NAME}-${BFDEV_NAME} "
"${BFDEV_VERSION}.${BFDEV_ARCH} "
"${BFDEV_COMMITID}-${BFDEV_BRANCH} "
"(${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION} ${CMAKE_HOST_SYSTEM_NAME}) "
"${BFDEV_BUILD_TIME}"
)
option(BFDEV_DEVEL "Enable development mode" OFF)
option(BFDEV_STRICT "Enable strict compilation" OFF)
option(BFDEV_EXAMPLES "Build examples" OFF)
option(BFDEV_TESTSUITE "Build testsuite" OFF)
option(BFDEV_ASAN "Enable Address Sanitizer" OFF)
option(BFDEV_UBSAN "Enable Undefined Behaviour Sanitizer" OFF)
option(BFDEV_GCOV "Enable Code Coverage Test" OFF)
option(BFDEV_DEBUG_LIST "Dynamic debug list" ON)
option(BFDEV_DEBUG_SLIST "Dynamic debug slist" ON)
option(BFDEV_DEBUG_HLIST "Dynamic debug hlist" ON)
option(BFDEV_DEBUG_ILIST "Dynamic debug ilist" ON)
option(BFDEV_DEBUG_RBTREE "Dynamic debug rbtree" ON)
option(BFDEV_DEBUG_HEAP "Dynamic debug heap" ON)
option(BFDEV_DEBUG_REFCNT "Dynamic debug refcnt" ON)
option(BFDEV_DEBUG_MEMALLOC "Dynamic debug memalloc" ON)
option(BFDEV_CRC_EXTEND "CRC loop unfolding optimize" ON)
if(BFDEV_DEVEL)
set(BFDEV_STRICT ON)
set(BFDEV_EXAMPLES ON)
set(BFDEV_TESTSUITE ON)
set(BFDEV_ASAN ON)
set(BFDEV_UBSAN ON)
set(BFDEV_GCOV ON)
endif()
include(${PROJECT_SOURCE_DIR}/build.cmake)
add_subdirectory(${PROJECT_SOURCE_DIR}/scripts)
packed_header(
bfdev/
_BFDEV_H_
${BFDEV_GENERATED_PATH}/bfdev.h
${BFDEV_HEADER_PATH}/bfdev
)
macro(bfdev_dependencies target)
add_dependencies(
${target}
gen-crc8
gen-crc16
gen-crc16be
gen-crc32
gen-crc32be
gen-crc64
gen-crc64be
)
endmacro()
add_library(bfdev_object OBJECT ${BFDEV_LIBRARY})
bfdev_dependencies(bfdev_object)
add_library(bfdev ALIAS bfdev_object)
if(BFDEV_EXAMPLES)
enable_testing()
add_subdirectory(examples)
endif()
if(BFDEV_TESTSUITE)
enable_testing()
add_subdirectory(testsuite)
endif()
if(${CMAKE_PROJECT_NAME} STREQUAL "bfdev")
add_library(bfdev_static STATIC ${BFDEV_LIBRARY})
add_library(bfdev_shared SHARED ${BFDEV_LIBRARY})
bfdev_dependencies(bfdev_static)
bfdev_dependencies(bfdev_shared)
set_target_properties(bfdev_static
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
LINKER_LANGUAGE C
)
set_target_properties(bfdev_shared
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
LINKER_LANGUAGE C
MACOSX_RPATH ON
)
install(FILES
${BFDEV_GENERATED_PATH}/bfdev.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(FILES
${PROJECT_SOURCE_DIR}/README.md
${PROJECT_SOURCE_DIR}/AUTHORS
${PROJECT_SOURCE_DIR}/COPYING
${PROJECT_SOURCE_DIR}/COPYING.LIB
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
install(FILES
${BFDEV_CONFIGURE}
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/bfdev
)
install(DIRECTORY
${BFDEV_HEADER_PATH}/bfdev
${BFDEV_GENERATED_PATH}/bfdev
${BFDEV_ARCH_HEADER_PATH}/bfdev
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(DIRECTORY
${BFDEV_DOCUMENT_PATH}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
)
install(TARGETS
bfdev_static bfdev_shared
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
endif()