-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
113 lines (90 loc) · 2.03 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
cmake_minimum_required(VERSION 3.10)
set(PROJECT_NAME lvnd)
set(CMAKE_BUILD_TYPE Release)
add_compile_options(
-O3
)
option(BUILD_USING_WAYLAND OFF)
set(LINUX False)
if (UNIX AND NOT APPLE)
set(LINUX True)
endif ()
set(PLATFORM)
set(PLATFORM_SRC_FILE_EXT c)
if (APPLE)
set(PLATFORM cocoa)
set(PLATFORM_SRC_FILE_EXT m)
elseif (LINUX)
if (BUILD_USING_WAYLAND)
set(PLATFORM wayland)
add_compile_definitions(
LVND_PLATFORM_WAYLAND
)
else ()
set(PLATFORM x11)
endif ()
elseif (WIN32)
set(PLATFORM win32)
endif ()
if (APPLE)
include_directories(
"/Users/samuliak/VulkanSDK/1.3.236.0/macOS/include"
)
endif ()
if (APPLE)
add_compile_options(
-Wno-deprecated-declarations
)
endif ()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
project(${PROJECT_NAME})
find_package(Vulkan REQUIRED)
file(GLOB src
src/*.c
src/${PLATFORM}/*.${PLATFORM_SRC_FILE_EXT}
src/vulkan/*.c
src/${PLATFORM}/vulkan/*.${PLATFORM_SRC_FILE_EXT}
src/opengl/*.c
src/${PLATFORM}/opengl/*.${PLATFORM_SRC_FILE_EXT}
)
add_library(${PROJECT_NAME} SHARED
${src}
)
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION 1)
include_directories(
"include"
)
if (APPLE)
find_library(QUARTZCORE_LIB QuartzCore)
target_link_libraries(${PROJECT_NAME}
"-framework Cocoa"
${QUARTZCORE_LIB}
)
elseif (LINUX)
find_package(X11 REQUIRED)
target_link_libraries(${PROJECT_NAME}
${X11_LIBRARIES}
-lGL
)
elseif (WIN32)
#TODO: add windows-specific libraries
endif ()
if (APPLE)
find_library (
Vulkan_LIBRARIES
NAMES vulkan libvulkan # what to look for
HINTS "/Users/samuliak/VulkanSDK/1.3.236.0/macOS/lib" # where to look
)
endif ()
target_link_libraries(${PROJECT_NAME}
${Vulkan_LIBRARIES}
)
if (APPLE)
file(GLOB metalSrc
src/metal/*.c
src/${PLATFORM}/metal/*.m
)
target_sources(${PROJECT_NAME} PRIVATE
${metalSrc}
)
endif ()