-
Notifications
You must be signed in to change notification settings - Fork 20
/
CMakeLists.txt
71 lines (55 loc) · 1.91 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
cmake_minimum_required(VERSION 3.14) # CMake version check
project("liburing4cpp")
set(libname "liburing4cpp")
set(CMAKE_CXX_STANDARD 20)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "-fcoroutines")
endif()
add_library("${libname}" INTERFACE)
#######################
## Find dependencies ##
#######################
# Find a threads library
find_package(Threads REQUIRED)
# Defines helper functions, like find_or_fetch
include(FetchContent)
include(functions.cmake)
find_or_fetch(
fmt # Package Name
https://github.com/fmtlib/fmt.git # Repository
master) # Branch (or commit or tag)
# find_or_fetch adds stuff to a list called remote_dependencies
note("Remote dependencies: ${remote_dependencies}")
FetchContent_MakeAvailable(${remote_dependencies})
###################
## Configuration ##
###################
# This creates a file compile_commands.json in the build directory
# That contains the compile commands used to actually compile the project
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Use pthreads as the Threads library, if availible
set(THREADS_PREFER_PTHREAD_FLAG ON)
########################
## Define the library ##
########################
target_include_directories(
${libname}
INTERFACE
include/)
# The library has fmt, uring, and Threads::Threads as dependencies
target_link_libraries(
${libname}
INTERFACE
fmt uring Threads::Threads)
##############################################
## Build demo when the project is top level ##
##############################################
# NB: If this project is included as a dependency as another project,
# Then demo won't get built
if (PROJECT_IS_TOP_LEVEL)
note("${PROJECT_NAME} is top level. Building demo projects")
# Target all the source files in demo
add_source_dir("demo" ${libname})
include(CTest)
add_test_dir("tests" ${libname})
endif()