-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (79 loc) · 2.76 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
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 STATIC)
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 -std=c89 -pedantic -Wall -Wextra)
endif()
target_include_directories(eui PUBLIC ${PROJECT_SOURCE_DIR}/include)
# sdl2 bridge library
find_package(SDL2)
if(SDL2_FOUND)
add_library(eui_sdl2 STATIC)
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 -std=c89 -pedantic -Wall -Wextra)
endif()
target_link_libraries(eui_sdl2 PUBLIC eui SDL2::SDL2)
endif()
# examples
if(EUI_BUILD_EXAMPLES)
# sdl2
if(SDL2_FOUND)
# 8bpp
foreach(example hello order font windows standalone cursor widgets bitmap)
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 hello order font windows standalone cursor widgets)
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()
# dos
if(${CMAKE_SYSTEM_NAME} STREQUAL DOS)
foreach(example hello order font windows standalone)
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()