-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
206 lines (165 loc) · 5.51 KB
/
CMakeLists.txt
File metadata and controls
206 lines (165 loc) · 5.51 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
cmake_minimum_required(VERSION 3.28)
project(eui
DESCRIPTION "UI and drawing library with a small footprint written in C89"
HOMEPAGE_URL "https://github.com/erysdren/eui"
LANGUAGES C
VERSION 0.0.2
)
# options
option(EUI_BUILD_EXAMPLES "Build EUI Examples" ON)
# library
add_library(eui)
add_library(eui::eui ALIAS eui)
target_sources(eui PRIVATE
${PROJECT_SOURCE_DIR}/source/eui.c
${PROJECT_SOURCE_DIR}/source/eui_evnt.c
${PROJECT_SOURCE_DIR}/source/eui_widg.c
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(eui PRIVATE -pedantic -Wall -Wextra)
endif()
set_target_properties(eui PROPERTIES C_STANDARD 90 C_STANDARD_REQUIRED ON)
target_include_directories(eui
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/source>
)
# sdl2 bridge library
find_package(SDL2 REQUIRED CONFIG REQUIRED COMPONENTS SDL2)
if(SDL2_FOUND)
add_library(eui_sdl2)
add_library(eui::sdl2 ALIAS eui_sdl2)
target_sources(eui_sdl2 PRIVATE
${PROJECT_SOURCE_DIR}/source/eui_sdl2.c
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(eui_sdl2 PRIVATE -pedantic -Wall -Wextra)
endif()
set_target_properties(eui_sdl2 PROPERTIES C_STANDARD 90 C_STANDARD_REQUIRED ON)
target_link_libraries(eui_sdl2 PUBLIC eui SDL2::SDL2)
endif()
# sdl3 bridge library
find_package(SDL3 REQUIRED CONFIG REQUIRED COMPONENTS SDL3)
if(SDL3_FOUND)
add_library(eui_sdl3)
add_library(eui::sdl3 ALIAS eui_sdl3)
target_sources(eui_sdl3 PRIVATE
${PROJECT_SOURCE_DIR}/source/eui_sdl3.c
)
if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_options(eui_sdl3 PRIVATE -pedantic -Wall -Wextra)
endif()
set_target_properties(eui_sdl3 PROPERTIES C_STANDARD 90 C_STANDARD_REQUIRED ON)
target_link_libraries(eui_sdl3 PUBLIC eui SDL3::SDL3)
endif()
# examples
if(EUI_BUILD_EXAMPLES)
set(examples hello order font windows standalone)
set(examples_interactive cursor widgets)
set(examples_8bpp bitmap)
# sdl2
if(SDL2_FOUND)
# 8bpp
foreach(example IN LISTS examples examples_interactive examples_8bpp)
add_executable(${example}_sdl2)
target_sources(${example}_sdl2 PUBLIC
${PROJECT_SOURCE_DIR}/examples/harness_sdl2.c
${PROJECT_SOURCE_DIR}/examples/${example}.c
)
target_compile_definitions(${example}_sdl2 PUBLIC EXAMPLE_FUNC=example_${example})
if(${example} STREQUAL "standalone")
target_compile_definitions(${example}_sdl2 PUBLIC EXAMPLE_STANDALONE=1)
endif()
target_link_libraries(${example}_sdl2 eui_sdl2)
endforeach()
# 4bpp
foreach(example IN LISTS examples examples_interactive)
add_executable(${example}_sdl2_4bpp)
target_sources(${example}_sdl2_4bpp PUBLIC
${PROJECT_SOURCE_DIR}/examples/harness_sdl2_4bpp.c
${PROJECT_SOURCE_DIR}/examples/${example}.c
)
target_compile_definitions(${example}_sdl2_4bpp PUBLIC EXAMPLE_FUNC=example_${example})
if(${example} STREQUAL "standalone")
target_compile_definitions(${example}_sdl2_4bpp PUBLIC EXAMPLE_STANDALONE=1)
endif()
target_link_libraries(${example}_sdl2_4bpp eui_sdl2)
endforeach()
endif()
# sdl3
if(SDL3_FOUND)
# 8bpp
foreach(example IN LISTS examples examples_interactive examples_8bpp)
add_executable(${example}_sdl3)
target_sources(${example}_sdl3 PUBLIC
${PROJECT_SOURCE_DIR}/examples/harness_sdl3.c
${PROJECT_SOURCE_DIR}/examples/${example}.c
)
target_compile_definitions(${example}_sdl3 PUBLIC EXAMPLE_FUNC=example_${example})
if(${example} STREQUAL "standalone")
target_compile_definitions(${example}_sdl3 PUBLIC EXAMPLE_STANDALONE=1)
endif()
target_link_libraries(${example}_sdl3 eui_sdl3)
endforeach()
# 4bpp
foreach(example IN LISTS examples examples_interactive)
add_executable(${example}_sdl3_4bpp)
target_sources(${example}_sdl3_4bpp PUBLIC
${PROJECT_SOURCE_DIR}/examples/harness_sdl3_4bpp.c
${PROJECT_SOURCE_DIR}/examples/${example}.c
)
target_compile_definitions(${example}_sdl3_4bpp PUBLIC EXAMPLE_FUNC=example_${example})
if(${example} STREQUAL "standalone")
target_compile_definitions(${example}_sdl3_4bpp PUBLIC EXAMPLE_STANDALONE=1)
endif()
target_link_libraries(${example}_sdl3_4bpp eui_sdl3)
endforeach()
endif()
# dos
if(CMAKE_SYSTEM_NAME STREQUAL "DOS")
foreach(example IN LISTS examples)
add_executable(${example}_dos)
target_sources(${example}_dos PUBLIC
${PROJECT_SOURCE_DIR}/examples/harness_dos.c
${PROJECT_SOURCE_DIR}/examples/${example}.c
)
target_compile_definitions(${example}_dos PUBLIC EXAMPLE_FUNC=example_${example})
if(${example} STREQUAL "standalone")
target_compile_definitions(${example}_dos PUBLIC EXAMPLE_STANDALONE=1)
endif()
target_link_libraries(${example}_dos eui)
endforeach()
endif()
endif()
# install
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_file(${PROJECT_SOURCE_DIR}/cmake/eui.pc.in ${PROJECT_BINARY_DIR}/eui.pc @ONLY)
write_basic_package_version_file(${PROJECT_BINARY_DIR}/eui-config-version.cmake COMPATIBILITY AnyNewerVersion)
install(
FILES ${PROJECT_BINARY_DIR}/eui.pc
DESTINATION lib/pkgconfig
)
install(
TARGETS eui
EXPORT eui-targets
INCLUDES DESTINATION include
)
install(
EXPORT eui-targets
DESTINATION lib/cmake
NAMESPACE eui::
FILE eui-config.cmake
)
install(
FILES ${PROJECT_BINARY_DIR}/eui-config-version.cmake
DESTINATION lib/cmake
)
install(
DIRECTORY
"${PROJECT_SOURCE_DIR}/include/"
TYPE INCLUDE
FILES_MATCHING PATTERN "*.h"
)