generated from bsamseth/cpp-project
-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
95 lines (81 loc) · 3.92 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
# This file specifies how the project should be built, using CMake.
# If you are unfamiliar with CMake, don't worry about all the details.
# The sections you might want to edit are marked as such, and
# the comments should hopefully make most of it clear.
#
# For many purposes, you may not need to change anything about this file.
cmake_minimum_required(VERSION 3.14)
# Set project name, version and laguages here. (change as needed)
# Version numbers are available by including "exampleConfig.h" in
# the source. See exampleConfig.h.in for some more details.
project(SHAREDSTATE VERSION 0.0.0.1 LANGUAGES CXX)
add_compile_options("-fcoroutines")
# Options: Things you can set via commandline options to cmake (e.g. -DENABLE_LTO=[ON|OFF])
option(ENABLE_WARNINGS_SETTINGS "Allow target_set_warnings to add flags and defines.
Set this to OFF if you want to provide your own warning parameters." OFF)
option(ENABLE_LTO "Enable link time optimization" ON)
option(ENABLE_DOCTESTS "Include tests in the library. Setting this to OFF will remove all doctest related code.
Tests in tests/*.cpp will still be enabled." ON)
# Include stuff. No change needed.
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
#include(ConfigSafeGuards)
include(Colors)
include(CTest)
include(Doctest)
include(Documentation)
include(LTO)
include(Misc)
include(Warnings)
# Check for LTO support.
find_lto(CXX)
# --------------------------------------------------------------------------------
# Locate files (change as needed).
# --------------------------------------------------------------------------------
set(SOURCES # All .cpp files in src/
src/io_context.cc
src/sharedstate.cc
src/socket_accept_operation.cc
src/socket.cc
src/socket_recv_operation.cc
src/socket_send_operation.cc
src/shared_state_error_code.cc
src/file_read_operation.cc
src/popen_async_command.cc
src/piped_async_command.cc
src/popen_file_read_operation.cc
src/file_write_operation.cc
src/dying_process_wait_operation.cc
src/debug/rsdebug.cc
)
set(TESTFILES # All .cpp files in tests/
tests/main.cpp
)
set(LIBRARY_NAME engine) # Default name for the library built from src/*.cpp (change if you wish)
# --------------------------------------------------------------------------------
# Build! (Change as needed)
# --------------------------------------------------------------------------------
# Compile all sources into a library.
add_library(${LIBRARY_NAME} OBJECT ${SOURCES})
# Lib needs its header files, and users of the library must also see these (PUBLIC). (No change needed)
target_include_directories(${LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/include)
# There's also (probably) doctests within the library, so we need to see this as well.
target_link_libraries(${LIBRARY_NAME} PUBLIC doctest)
# Set the compile options you want (change as needed).
target_set_warnings(${LIBRARY_NAME} ENABLE ALL AS_ERROR ALL DISABLE Annoying)
# target_compile_options(${LIBRARY_NAME} ... ) # For setting manually.
# Add an executable for the file app/main.cpp.
# If you add more executables, copy these lines accordingly.
add_executable(main app/main.cc) # Name of exec. and location of file.
target_link_libraries(main PRIVATE ${LIBRARY_NAME}) # Link the executable to library (if it uses it).
target_set_warnings(main ENABLE ALL AS_ERROR ALL DISABLE Annoying) # Set warnings (if needed).
target_enable_lto(main optimized) # enable link-time-optimization if available for non-debug configurations
# Set the properties you require, e.g. what C++ standard to use. Here applied to library and main (change as needed).
set_target_properties(
${LIBRARY_NAME} main
PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED YES
#CXX_EXTENSIONS YES
)
# Set up tests (see tests/CMakeLists.txt).
add_subdirectory(tests)