Skip to content

Commit 21e3d25

Browse files
committed
build(all): extern liburingcxx; use configure, no -D
1 parent 9278e4f commit 21e3d25

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+1557
-284
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ draft/
7474
*.rdb
7575
*.svg
7676
/perf/
77-
perf.data*
77+
/perf.*
7878
*.data
7979
*.perf
8080
*.folded

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
cmake_minimum_required(VERSION 3.13)
22

33
project(co_context
4-
VERSION 0.9.0
4+
VERSION 0.10.0
55
LANGUAGES CXX)
66

77
include(cmake/Policy.cmake NO_POLICY_SCOPE)
88

9+
add_subdirectory(extern/liburingcxx)
10+
911
add_library(co_context STATIC)
1012
add_library(co_context::co_context ALIAS co_context)
13+
target_link_libraries(co_context PUBLIC liburingcxx::liburingcxx)
1114
target_include_directories(co_context
1215
PUBLIC
1316
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
@@ -19,6 +22,7 @@ include(cmake/CompileOption.cmake)
1922
include(cmake/Platform.cmake)
2023
include(cmake/Develop.cmake)
2124
include(cmake/Extra.cmake)
25+
include(cmake/Configure.cmake)
2226
include(cmake/Install.cmake)
2327

2428
add_subdirectory(lib)

cmake/CompileOption.cmake

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,17 @@ else()
3636
endif()
3737

3838
if (mi_version)
39-
target_compile_definitions(co_context PRIVATE CO_CONTEXT_USE_MIMALLOC)
40-
set(USE_MIMALLOC ON)
39+
set(CO_CONTEXT_USE_MIMALLOC ON)
4140
message(NOTICE "mimalloc ${mi_version} enabled")
4241
else()
43-
set(USE_MIMALLOC OFF)
42+
set(CO_CONTEXT_USE_MIMALLOC OFF)
4443
message(WARNING "mimalloc disabled")
4544
endif()
4645

4746
set(THREADS_PREFER_PTHREAD_FLAG ON)
4847
find_package(Threads REQUIRED)
4948
target_link_libraries(co_context PUBLIC Threads::Threads)
5049

51-
if (USE_MIMALLOC)
50+
if (CO_CONTEXT_USE_MIMALLOC)
5251
target_link_libraries(co_context PUBLIC mimalloc)
5352
endif()
54-
55-
if (co_context_no_generator) # set by check/check_compile.cmake
56-
target_compile_definitions(co_context PUBLIC CO_CONTEXT_NO_GENERATOR)
57-
endif()
58-
59-
if (NOT co_context_has_kernel_rwf_t) # set by check/check_compile.cmake
60-
target_compile_definitions(co_context PUBLIC CO_CONTEXT_OFFER_KERNEL_RWF_T)
61-
endif()

cmake/Configure.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
configure_file(
2+
${PROJECT_SOURCE_DIR}/include/co_context/config/config.hpp.in
3+
${PROJECT_SOURCE_DIR}/include/co_context/config/config.hpp
4+
@ONLY
5+
)

cmake/Install.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ install(DIRECTORY "${co_context_SOURCE_DIR}/include/co_context"
1212
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
1313
)
1414

15-
install(DIRECTORY "${co_context_SOURCE_DIR}/include/uring"
16-
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
17-
)
18-
1915
install(EXPORT co_context_targets
2016
FILE co_context_targets.cmake
2117
NAMESPACE co_context::

cmake/Platform.cmake

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,6 @@
11
# ----------------------------------------------------------------------------
22
# Linux
33
# ----------------------------------------------------------------------------
4-
# Get the linux kernel version to liburingcxx
5-
message(STATUS "target_kernel_version = ${CMAKE_SYSTEM_VERSION}")
6-
set(kernel_version ${CMAKE_SYSTEM_VERSION})
7-
string(REGEX MATCH "^([0-9]+)\.([0-9]+)" kernel_version ${kernel_version})
8-
string(REGEX MATCH "^([0-9]+)" kernel_version_major ${kernel_version})
9-
string(REGEX REPLACE "^([0-9]+)\\." "" kernel_version_minor ${kernel_version})
10-
message(STATUS "kernel_version_major = ${kernel_version_major}")
11-
message(STATUS "kernel_version_minor = ${kernel_version_minor}")
12-
target_compile_definitions(co_context
13-
PUBLIC "$<BUILD_INTERFACE:LIBURINGCXX_KERNEL_VERSION_MAJOR=${kernel_version_major}>"
14-
PUBLIC "$<BUILD_INTERFACE:LIBURINGCXX_KERNEL_VERSION_MINOR=${kernel_version_minor}>"
15-
)
16-
unset(kernel_version)
174

185
# ----------------------------------------------------------------------------
196
# Gcc

cmake/check/check_compile.cmake

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
1010
endif()
1111
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "11.3.0")
1212
message(NOTICE "co_context::generator will be disabled for insufficient gcc version (requires gcc 11.3 or above).")
13-
set(co_context_no_generator ON)
13+
set(CO_CONTEXT_NO_GENERATOR ON)
1414
endif()
1515
endif()
1616

@@ -20,19 +20,6 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
2020
endif()
2121
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0.0")
2222
message(NOTICE "co_context::generator will be disabled for insufficient clang version (requires clang 17 or above).")
23-
set(co_context_no_generator ON)
23+
set(CO_CONTEXT_NO_GENERATOR ON)
2424
endif()
2525
endif()
26-
27-
check_cxx_source_runs(
28-
[====[
29-
#include <linux/fs.h>
30-
int main(int argc, char **argv)
31-
{
32-
__kernel_rwf_t x;
33-
x = 0;
34-
return x;
35-
}
36-
]====]
37-
co_context_has_kernel_rwf_t
38-
)

cmake/templates/Config.cmake.in

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,6 @@ include(CMakeFindDependencyMacro)
44
find_dependency(Threads REQUIRED)
55
find_dependency(mimalloc QUIET)
66

7-
# Get the linux kernel version to liburingcxx
8-
message(STATUS "target_kernel_version = ${CMAKE_SYSTEM_VERSION}")
9-
set(kernel_version ${CMAKE_SYSTEM_VERSION})
10-
string(REGEX MATCH "^([0-9]+)\.([0-9]+)" kernel_version ${kernel_version})
11-
string(REGEX MATCH "^([0-9]+)" kernel_version_major ${kernel_version})
12-
string(REGEX REPLACE "^([0-9]+)\\." "" kernel_version_minor ${kernel_version})
13-
message(STATUS "kernel_version_major = ${kernel_version_major}")
14-
message(STATUS "kernel_version_minor = ${kernel_version_minor}")
15-
add_compile_definitions(LIBURINGCXX_KERNEL_VERSION_MAJOR=${kernel_version_major})
16-
add_compile_definitions(LIBURINGCXX_KERNEL_VERSION_MINOR=${kernel_version_minor})
17-
unset(kernel_version)
18-
197
include("${CMAKE_CURRENT_LIST_DIR}/co_context_targets.cmake")
208

219
check_required_components(co_context)

example/iota.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#ifndef CO_CONTEXT_NO_GENERATOR
1+
#if !CO_CONTEXT_NO_GENERATOR
22

33
#include <co_context/generator.hpp>
44

@@ -22,7 +22,7 @@ int main() {
2222
return 0;
2323
}
2424

25-
#else // ifndef CO_CONTEXT_NO_GENERATOR
25+
#else // if !CO_CONTEXT_NO_GENERATOR
2626

2727
#include <iostream>
2828

extern/liburingcxx/.clang-format

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
BasedOnStyle: LLVM
3+
IndentWidth: 4
4+
TabWidth: 4
5+
Language: Cpp
6+
AlignAfterOpenBracket: BlockIndent # BlockIndent
7+
AlignArrayOfStructures: Right
8+
AlignConsecutiveBitFields: "Consecutive"
9+
AlignConsecutiveMacros: "Consecutive"
10+
AlignEscapedNewlines: Left
11+
AlignOperands: "Align"
12+
AlignTrailingComments: true
13+
AllowAllArgumentsOnNextLine: true
14+
AllowAllConstructorInitializersOnNextLine: true
15+
AllowAllParametersOfDeclarationOnNextLine: true
16+
AlignConsecutiveShortCaseStatements: # clang-format 17
17+
Enabled: true
18+
AcrossEmptyLines: true
19+
AcrossComments: true
20+
AlignCaseColons: false
21+
AllowShortBlocksOnASingleLine: Empty
22+
AllowShortCaseLabelsOnASingleLine: true
23+
AllowShortEnumsOnASingleLine: true
24+
AllowShortFunctionsOnASingleLine: InlineOnly
25+
AllowShortIfStatementsOnASingleLine: WithoutElse
26+
AllowShortLambdasOnASingleLine: Inline
27+
AllowShortLoopsOnASingleLine: false
28+
AlwaysBreakBeforeMultilineStrings: false
29+
AlwaysBreakTemplateDeclarations: Yes
30+
BinPackArguments: true
31+
BinPackParameters: false
32+
BreakAfterAttributes: Leave # clang-format 16
33+
BreakBeforeBinaryOperators: NonAssignment
34+
BreakBeforeBraces: Attach
35+
BreakBeforeConceptDeclarations: true
36+
BreakBeforeTernaryOperators: true
37+
BreakConstructorInitializers: BeforeComma
38+
BreakInheritanceList: BeforeComma
39+
BreakStringLiterals: false
40+
ColumnLimit: 80
41+
CompactNamespaces: false
42+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
43+
ConstructorInitializerIndentWidth: 4
44+
ContinuationIndentWidth: 4
45+
Cpp11BracedListStyle: true
46+
EmptyLineBeforeAccessModifier: Always
47+
FixNamespaceComments: true
48+
IndentCaseLabels: true
49+
IndentExternBlock: Indent
50+
IndentGotoLabels: true
51+
IndentPPDirectives: None
52+
IndentRequires: true # clang-format 14
53+
IndentWrappedFunctionNames: false
54+
InsertBraces: true # clang-format 15
55+
InsertNewlineAtEOF: true # clang-format 16
56+
IntegerLiteralSeparator: # clang-format 16
57+
Binary: 8
58+
Decimal: 0
59+
Hex: 2
60+
HexMinDigits: 8
61+
LambdaBodyIndentation: Signature
62+
LineEnding: LF # clang-format 16
63+
KeepEmptyLinesAtEOF: false # clang-format 17
64+
KeepEmptyLinesAtTheStartOfBlocks: false
65+
MaxEmptyLinesToKeep: 1
66+
NamespaceIndentation: Inner
67+
PackConstructorInitializers: CurrentLine # clang-format 14
68+
PointerAlignment: Right
69+
QualifierAlignment: Left
70+
ReflowComments: true
71+
RequiresClausePosition: OwnLine # clang-format 15
72+
RequiresExpressionIndentation: OuterScope # clang-format 16
73+
SeparateDefinitionBlocks: Always
74+
ShortNamespaceLines: 5
75+
SortIncludes: "CaseSensitive"
76+
SortUsingDeclarations: false
77+
SpaceAfterCStyleCast: false
78+
SpaceAfterLogicalNot: false
79+
SpaceAfterTemplateKeyword: false
80+
SpaceBeforeAssignmentOperators: true
81+
SpaceBeforeCpp11BracedList: false
82+
SpaceBeforeCtorInitializerColon: true
83+
SpaceBeforeInheritanceColon: true
84+
SpaceBeforeParens: ControlStatements
85+
SpaceBeforeRangeBasedForLoopColon: true
86+
SpaceBeforeSquareBrackets: false
87+
SpaceInEmptyBlock: false
88+
SpaceInEmptyParentheses: false
89+
SpacesBeforeTrailingComments: 1
90+
SpacesInAngles: "Never"
91+
SpacesInCStyleCastParentheses: false
92+
SpacesInConditionalStatement: false
93+
SpacesInContainerLiterals: true
94+
SpacesInParentheses: false
95+
SpacesInSquareBrackets: false
96+
Standard: Latest
97+
UseCRLF: false
98+
UseTab: Never
99+
...

extern/liburingcxx/.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Prerequisites
2+
*.d
3+
4+
# Compiled Object files
5+
*.slo
6+
*.lo
7+
*.o
8+
*.obj
9+
10+
# Precompiled Headers
11+
*.gch
12+
*.pch
13+
14+
# Compiled Dynamic libraries
15+
*.so
16+
*.dylib
17+
*.dll
18+
19+
# Fortran module files
20+
*.mod
21+
*.smod
22+
23+
# Compiled Static libraries
24+
*.lai
25+
*.la
26+
*.a
27+
*.lib
28+
29+
# Executables
30+
*.exe
31+
*.out
32+
*.app
33+
34+
# CMake
35+
build/
36+
CMakeLists.txt.user
37+
CMakeCache.txt
38+
CMakeFiles
39+
CMakeScripts
40+
Testing
41+
Makefile
42+
cmake_install.cmake
43+
install_manifest.txt
44+
compile_commands.json
45+
CTestTestfile.cmake
46+
_deps
47+
48+
# Visual Studio Code
49+
.vscode/
50+
51+
# Local History for Visual Studio Code
52+
.history/
53+
54+
# clangd
55+
.cache/
56+
57+
# Built Visual Studio Code Extensions
58+
*.vsix
59+
60+
draft/
61+
62+
perf.data*
63+
*.data
64+
65+
# log for perf
66+
log
67+
tmp
68+
*.rdb
69+
*.svg
70+
71+
# public/index.html for httpd
72+
public/

extern/liburingcxx/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.10.0)
2+
3+
set(CMAKE_CXX_STANDARD 20)
4+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5+
6+
project(liburingcxx VERSION 0.9.0 LANGUAGES CXX)
7+
8+
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
9+
message(WARNING "io_uring is only supported by Linux, but the target OS is ${CMAKE_SYSTEM_NAME}.")
10+
endif()
11+
12+
add_library(liburingcxx INTERFACE)
13+
add_library(liburingcxx::liburingcxx ALIAS liburingcxx)
14+
15+
target_include_directories(
16+
liburingcxx
17+
INTERFACE
18+
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
19+
"$<INSTALL_INTERFACE:include>"
20+
)
21+
22+
include(./cmake/option.cmake)
23+
include(./cmake/configure.cmake)
24+
include(./cmake/install.cmake)
25+
26+
if (LIBURINGCXX_BUILD_EXAMPLE OR LIBURINGCXX_BUILD_TEST)
27+
if (NOT CMAKE_BUILD_TYPE)
28+
set(CMAKE_BUILD_TYPE Release)
29+
message("liburingcxx: Setting default CMAKE_BUILD_TYPE to Release.")
30+
endif()
31+
32+
if(LIBURINGCXX_BUILD_TEST)
33+
add_subdirectory(./test)
34+
endif()
35+
36+
if(LIBURINGCXX_BUILD_EXAMPLE)
37+
add_subdirectory(./example)
38+
endif()
39+
endif()

0 commit comments

Comments
 (0)