-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
129 lines (114 loc) · 3.31 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 3.8)
project("gpuimageviewer" CXX)
# set standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# add global compile options
if(MSVC)
add_compile_options(/MT)
add_compile_options(/MP)
add_compile_options(/nologo)
# add_compile_options("$<$<CONFIG:Release>:/fp:strict>")
add_compile_options("$<$<CONFIG:Release>:/Ox>")
add_compile_options("$<$<CONFIG:Release>:/GL>")
add_compile_options("$<$<CONFIG:Release>:/Y->")
add_link_options("$<$<CONFIG:Release>:/LTCG>")
else()
add_compile_options("$<$<CONFIG:Release>:-O2>")
add_compile_options("$<$<CONFIG:Release>:-fomit-frame-pointer>")
add_compile_options("$<$<CONFIG:Release>:-fno-exceptions>")
add_compile_options("$<$<CONFIG:Release>:-pipe>")
endif()
# set pthreads
if(NOT MSVC)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
endif()
# SDL options
set(SDL_STATIC
ON
CACHE BOOL "" FORCE)
set(SDL_SHARED
OFF
CACHE BOOL "" FORCE)
set(SUPPORT_PNG
ON
CACHE BOOL "" FORCE)
set(BUILD_SHARED_LIBS
OFF
CACHE BOOL "" FORCE)
set(SDLIMAGE_AVIF
OFF
CACHE BOOL "" FORCE)
set(SDL_DISABLE_UNINSTALL
ON
CACHE BOOL "" FORCE)
set(FLTK_BUILD_SHARED_LIBS
OFF
CACHE BOOL "" FORCE)
set(FLTK_BUILD_FLUID
OFF
CACHE BOOL "" FORCE)
set(FLTK_BUILD_FLTK_OPTIONS
OFF
CACHE BOOL "" FORCE)
set(FLTK_BUILD_TEST
OFF
CACHE BOOL "" FORCE)
set(FLTK_BUILD_EXAMPLES
OFF
CACHE BOOL "" FORCE)
# FIXME:
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/deps/SDL/SDL_Image/include/SDL3_image)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/deps/SDL/SDL/include/SDL3)
add_subdirectory(deps/SDL/SDL)
add_subdirectory(deps/SDL/SDL_Image)
add_subdirectory(deps/fltk)
# add executable
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/interfaces)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/gfx)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/platform)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/stuff)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/gfx SUB_SOURCES)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/platform SUB_SOURCES)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR}/ SUB_SOURCES)
add_executable(${PROJECT_NAME} ${SUB_SOURCES})
# link and private compile options
find_package(Threads REQUIRED)
target_link_libraries(
${PROJECT_NAME} PRIVATE SDL3::SDL3-static SDL3_image-static Threads::Threads
fltk)
add_definitions(-DFLTK_USE_CAIRO=0)
if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4)
else()
target_compile_options(
${PROJECT_NAME}
PRIVATE -Wall
-Wextra
-Wpedantic
-pedantic
# -Werror
-Wfatal-errors
-Wshadow
-Wunused
-Wdouble-promotion
-Wundef
-Wconversion
-fstack-protector-all
-fstack-protector-strong
-Werror=format-security
-D_FORTIFY_SOURCE=2
-D_GLIBCXX_ASSERTIONS
-fpie)
endif()
if(MSVC)
file(COPY renderer.txt DESTINATION ${CMAKE_BINARY_DIR}/${CMAKE_BUILD_TYPE})
else()
file(COPY renderer.txt DESTINATION ${CMAKE_BINARY_DIR})
endif()