This repository has been archived by the owner on Feb 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
80 lines (63 loc) · 2.29 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
# Core main CMakeLists with all sub projects
cmake_minimum_required (VERSION 3.14)
project ("Core" VERSION 3.0)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if(OPTIMIZATION)
add_compile_options(${OPTIMIZATION})
endif()
if (MSVC)
# warning level 4
add_compile_options(/W4)
else()
# lots of warnings
add_compile_options(-Wall -Wextra -pedantic)
endif()
option(USE_INJA "Use Inja" ON)
option(RUN_TESTS "Run unit & integration tests" ON)
configure_file(Core.hpp.in ${CMAKE_CURRENT_SOURCE_DIR}/lib/core/Core-version.hpp)
if (WIN32)
list(APPEND EXTRA_LIBS wsock32 ws2_32)
endif()
find_package(Threads REQUIRED)
list(APPEND EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT})
if(CMAKE_USE_PTHREADS_INIT)
add_definitions(-DUSE_PTHREAD)
endif()
# Include sub-projects.
if(USE_INJA)
add_subdirectory("lib/inja")
add_definitions(-DUSE_INJA)
list(APPEND EXTRA_LIBS single_inja)
endif()
add_library(Core STATIC "lib/core/core.cpp")
target_link_libraries(Core PUBLIC ${EXTRA_LIBS})
target_include_directories(Core INTERFACE "${CMAKE_CURRENT_SOURCE_DIR}/lib")
set_target_properties(Core PROPERTIES LINKER_LANGUAGE CXX)
install(TARGETS Core DESTINATION ${PROJECT_BINARY_DIR})
if(RUN_TESTS)
message("Core-Tests build:")
add_subdirectory("tests/")
endif()
# Generate example source code
add_executable(BenchmarkNormal benchmark/contestants/server.cpp)
target_link_libraries(BenchmarkNormal PUBLIC Core)
target_include_directories(BenchmarkNormal PUBLIC
"${PROJECT_BINARY_DIR}"
)
add_executable(BenchmarkAtomic benchmark/contestants/server_atomic.cpp)
target_link_libraries(BenchmarkAtomic PUBLIC Core)
target_include_directories(BenchmarkAtomic PUBLIC
"${PROJECT_BINARY_DIR}"
)
add_executable(SampleExample example/Sample/main.cpp)
target_link_libraries(SampleExample PUBLIC Core)
target_include_directories(SampleExample PUBLIC
"${PROJECT_BINARY_DIR}"
)
add_executable(ProjectExample example/Project/main.cpp)
target_link_libraries(ProjectExample PUBLIC Core)
target_include_directories(ProjectExample PUBLIC
"${PROJECT_BINARY_DIR}"
)
#include(CPack)