-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
129 lines (106 loc) · 3.66 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
cmake_minimum_required(VERSION 2.8)
project(mandelbrot C)
set(CONFIG_WARNING
"/*DO NOT EDIT THIS FILE IT WILL BE OVERWRITTEN\n* EDIT config.cmake INSTEAD!*/")
# This file contains main project compile time options.
# Edit this file to customize the build
include(config/config.cmake)
configure_file(config/config.h.in config/config.h @ONLY)
set(CMAKE_VERBOSE_MAKEFILE Off)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE -std=gnu99 -fPIC -fvisibility=hidden -Wall -Wextra -Wno-unused-function -Werror=declaration-after-statement")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -g -O0")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=leak")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=undefined")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=address")
#set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fsanitize=thread")
set(CFLAGS_RELEASE "-DNDEBUG -O3 -s -funroll-loops -ftree-vectorize")
#LTO works not properly on MinGW.
if(!WIN32)
set(CFLAGS_RELEASE "${CFLAGS_RELEASE} -flto")
endif()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${CFLAGS_RELEASE}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}
-DNDEBUG
-O3
-g
-flto
-ffast-math
-funroll-loops
-ftree-vectorize")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(SOURCE_FILES
app/main.c
config/config.h
sched/rsched.c
sched/rsched.h
tools/args_parser.c
tools/args_parser.h
tools/compiler.h
tools/log.c
tools/log.h
tools/atomic.h
tools/timer.h
tools/image_hdr.c
tools/image_hdr.h
app/benchmark.c
app/benchmark.h
app/render.c
app/render.h
kernel/mdb_kernel.c
kernel/mdb_kernel.h
kernel/mdb_kernel_meta.h
kernel/mdb_kernel_event.h
tools/cpu_features.c
tools/cpu_features.h
surface/surface.c
surface/surface.h
tools/error_codes.h
tools/hist.c
tools/hist.h
sched/rsched_queue.c
sched/rsched_queue.h
sched/rsched_worker.c
sched/rsched_worker.h
sched/rsched_common.h
sched/rsched_profile.c
sched/rsched_profile.h
tools/mem.h
tools/nproc.c
tools/nproc.h
)
if(CONFIG_OGL_RENDER)
if (${CMAKE_BUILD_TYPE} STREQUAL Debug)
include_directories(render/glad_debug/include/)
list(APPEND SOURCE_FILES render/glad_debug/src/glad.c)
elseif(${CMAKE_BUILD_TYPE} STREQUAL Release)
include_directories(render/glad_release/include/)
list(APPEND SOURCE_FILES render/glad_release/src/glad.c)
elseif(${CMAKE_BUILD_TYPE} STREQUAL RelWithDebInfo)
include_directories(render/glad_release/include/)
list(APPEND SOURCE_FILES render/glad_release/src/glad.c)
endif ()
list(APPEND SOURCE_FILES
render/ogl_render.c
render/ogl_render.h
render/ogl_shader.c
render/ogl_shader.h
render/ogl_pixel_buffer.c
render/ogl_pixel_buffer.h
render/ogl_squad.c
render/ogl_squad.h
render/ogl_buffer_sync.c
render/ogl_buffer_sync.h
)
endif()
add_executable(mdb ${SOURCE_FILES})
target_link_libraries(mdb pthread dl m)
if(CONFIG_OGL_RENDER)
target_link_libraries(mdb glfw)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shaders)
add_custom_command(
TARGET mdb POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/render/shaders
${CMAKE_CURRENT_BINARY_DIR}/shaders)
endif()
add_subdirectory(kernel_modules ${CMAKE_CURRENT_BINARY_DIR}/modules)