-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
104 lines (86 loc) · 2.49 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
# Copyright (C) 2024 dbstream
# As of writing this line of code, I have CMake 3.30 installed on my machine. To
# avoid any potential problems, simply require CMake 3.30.
cmake_minimum_required (VERSION 3.25)
# VKFW intentionally has a C-like API, but is written in C++.
# Enable C anyways, as it is used to compile Wayland protocol code.
project (vkfw LANGUAGES C CXX)
# Use C++17, as in my experience, C++20 and newer can cause linter issues.
set (CMAKE_CXX_STANDARD 17)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
add_library (vkfw)
find_package (Vulkan)
target_include_directories (vkfw PUBLIC ${Vulkan_INCLUDE_DIRS})
target_compile_definitions (vkfw PRIVATE -DVKFW_BUILDING)
if (BUILD_SHARED_LIBS)
target_compile_definitions (vkfw PUBLIC -DVKFW_DLL)
endif ()
target_include_directories (vkfw PUBLIC include)
# Generic sources.
target_sources (vkfw PRIVATE
"core/event.cc"
"core/keyboard.cc"
"core/logging.cc"
"core/vk_context.cc"
"core/vk_functions.cc"
"core/vkfw.cc"
"core/window.cc"
)
set (VKFW_WANT_WAYLAND OFF)
set (VKFW_WANT_XCB OFF)
# Platform-specific sources.
if (UNIX)
set (VKFW_WANT_WAYLAND ON)
set (VKFW_WANT_XCB ON)
target_sources (vkfw PRIVATE
"unix/platform.cc"
)
endif ()
if (WIN32)
target_compile_definitions (vkfw PRIVATE -DVKFW_USE_WIN32)
target_sources (vkfw PRIVATE
"win32/backend.cc"
"win32/event.cc"
"win32/platform.cc"
"win32/utils.cc"
"win32/window.cc"
)
endif ()
if (VKFW_WANT_WAYLAND)
target_compile_definitions (vkfw PRIVATE -DVKFW_USE_WAYLAND)
target_sources (vkfw PRIVATE
"wayland/connection.cc"
"wayland/event.cc"
"wayland/input.cc"
"wayland/viewporter-protocol.c"
"wayland/wayland-protocol.c"
"wayland/window.cc"
"wayland/xdg-shell-protocol.c"
"wayland/zxdg-decoration-v1-protocol.c"
)
endif ()
if (VKFW_WANT_XCB)
target_compile_definitions (vkfw PRIVATE -DVKFW_USE_XCB)
target_sources (vkfw PRIVATE
"xcb/connection.cc"
"xcb/event.cc"
"xcb/keyboard.cc"
"xcb/window.cc"
)
endif ()
if (PROJECT_IS_TOP_LEVEL)
add_executable (example)
# Make sure users of VKFW can compile without any warnings.
if (MSVC)
# FIXME: VKFWevent contains unnamed anonymous unions and
# structs. This is perfectly fine on GCC, but breaks MSVC.
#
# Mitigate this by compiling with /W3. I'm not sure if this
# fixes the problem.
target_compile_options (example PRIVATE /W3 /WX)
else ()
target_compile_options (example PRIVATE -Wall -Wextra -Werror)
endif ()
target_link_libraries (example vkfw)
target_sources (example PRIVATE "example.cc")
endif ()