-
Notifications
You must be signed in to change notification settings - Fork 0
/
CmakeLists.txt
209 lines (173 loc) · 5.18 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
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
206
207
208
209
cmake_minimum_required(VERSION 3.5...3.28)
set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum OS X deployment version")
project(
Neogurt
VERSION 0.1.5
DESCRIPTION "A Neovim GUI Smooth like Yogurt!"
LANGUAGES C CXX
)
if (DEV_BUILD)
execute_process(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(PROJECT_VERSION_SUFFIX "dev")
set(PROJECT_VERSION_COMMIT ${GIT_COMMIT_HASH})
set(PROJECT_VERSION "${PROJECT_VERSION}-${PROJECT_VERSION_SUFFIX}-${PROJECT_VERSION_COMMIT}")
endif()
# fix https://gitlab.kitware.com/cmake/cmake/-/issues/24104
enable_language(OBJC)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # clangd
# deps ---------------------------
set(Boost_USE_STATIC_LIBS ON)
find_package(Boost 1.86.0 REQUIRED COMPONENTS
process
program_options
)
add_subdirectory(deps/webgpu_tools EXCLUDE_FROM_ALL)
set(MSGPACK_USE_STATIC_BOOST ON)
add_subdirectory(deps/msgpack EXCLUDE_FROM_ALL)
add_subdirectory(deps/freetype EXCLUDE_FROM_ALL)
set(UTFCPP_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/deps/utfcpp/source)
# temp fix for https://github.com/blend2d/blend2d/issues/216
set(BLEND2D_NO_JIT OFF)
add_subdirectory(deps/blend2d EXCLUDE_FROM_ALL)
# neogurt target -------------------------
set(APP_SRC
main.cpp
app/sdl_window.cpp
app/sdl_event.cpp
app/input.cpp
app/size.cpp
app/window_funcs.mm
app/options.cpp
app/path.cpp
app/task_helper.cpp
editor/state.cpp
editor/cursor.cpp
editor/grid.cpp
editor/window.cpp
editor/highlight.cpp
editor/font.cpp
gfx/context.cpp
gfx/pipeline.cpp
gfx/renderer.cpp
gfx/font.cpp
gfx/pen.cpp
gfx/shape_drawing.cpp
gfx/camera.cpp
gfx/render_texture.cpp
gfx/texture_atlas.cpp
gfx/font/locator.mm
nvim/nvim.cpp
nvim/msgpack_rpc/client.cpp
nvim/events/ui.cpp
nvim/events/user.cpp
session/manager.cpp
utils/unicode.cpp
utils/clock.cpp
utils/logger.cpp
utils/timer.cpp
utils/color.cpp
)
list(TRANSFORM APP_SRC PREPEND "src/")
add_executable(neogurt ${APP_SRC})
target_compile_definitions(neogurt PRIVATE
VERSION="${PROJECT_VERSION}"
VERSION_MAJOR="${PROJECT_VERSION_MAJOR}"
VERSION_MINOR="${PROJECT_VERSION_MINOR}"
VERSION_PATCH="${PROJECT_VERSION_PATCH}"
VERSION_SUFFIX="${PROJECT_VERSION_SUFFIX}"
VERSION_COMMIT="${PROJECT_VERSION_COMMIT}"
ROOT_DIR="${PROJECT_SOURCE_DIR}"
)
target_include_directories(neogurt PRIVATE
${PROJECT_SOURCE_DIR}/src
${UTFCPP_INCLUDE_DIR}
)
# custom LLVM path in github actions, else use brew
if (NOT DEFINED ENV{LLVM_PATH})
execute_process(COMMAND brew --prefix llvm OUTPUT_VARIABLE LLVM_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
set(ENV{LLVM_PATH} ${LLVM_PATH})
endif()
target_link_libraries(neogurt PRIVATE
Boost::process
Boost::program_options
webgpu_tools
msgpack-cxx
freetype
blend2d::blend2d
# https://github.com/llvm/llvm-project/issues/77653
# stack unwinding breaking and linking breaks without this
"-L$ENV{LLVM_PATH}/lib/c++ -L$ENV{LLVM_PATH}/lib/unwind -lunwind"
)
target_compile_options(neogurt PRIVATE
-Wall -Wextra -Wshadow -pedantic
-Wno-missing-field-initializers
-Wno-deprecated-declarations
# jthread clang
-fexperimental-library
-Wno-error=narrowing
--embed-dir=${PROJECT_SOURCE_DIR}/res
)
if (XCODE)
target_compile_definitions(neogurt PRIVATE
XCODE=1
)
set_target_properties(neogurt PROPERTIES
XCODE_GENERATE_SCHEME ON
XCODE_SCHEME_ENABLE_GPU_FRAME_CAPTURE_MODE "Metal"
XCODE_SCHEME_ENVIRONMENT "PATH=$ENV{PATH};DAWN_DEBUG_BREAK_ON_ERROR=1"
XCODE_SCHEME_ADDRESS_SANITIZER ON
XCODE_SCHEME_UNDEFINED_BEHAVIOUR_SANITIZER ON
)
set(CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS "-o linker-signed")
set(CMAKE_XCODE_ATTRIBUTE_COMPILER_INDEX_STORE_ENABLE "No")
endif()
# app generation
if (CMAKE_BUILD_TYPE MATCHES RelWithDebInfo)
set(RESOURCE_DIR ${PROJECT_SOURCE_DIR}/res)
file(GLOB_RECURSE RESOURCE_FILES
"${RESOURCE_DIR}/shaders/*"
"${RESOURCE_DIR}/lua/*"
)
target_sources(neogurt PRIVATE
${RESOURCE_FILES}
)
if (APPLE)
foreach (FILE ${RESOURCE_FILES})
file(RELATIVE_PATH FILE_REL_PATH "${RESOURCE_DIR}" ${FILE})
get_filename_component(FILE_REL_DIR ${FILE_REL_PATH} DIRECTORY)
set_source_files_properties(${FILE} PROPERTIES
MACOSX_PACKAGE_LOCATION "Resources/${FILE_REL_DIR}"
)
endforeach()
set_target_properties(neogurt PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST "${RESOURCE_DIR}/Info.plist.in"
)
install(TARGETS neogurt
BUNDLE DESTINATION . COMPONENT Runtime
)
set(APPS "\${CMAKE_INSTALL_PREFIX}/Neogurt.app")
set(DIRS
${CMAKE_BINARY_DIR}/_deps/dawn-src/lib # libwebgpu_dawn.dylib
$ENV{LLVM_PATH}/lib/c++
$ENV{LLVM_PATH}/lib/unwind
)
install(CODE "
include(BundleUtilities)
fixup_bundle(\"${APPS}\" \"\" \"${DIRS}\")
")
install(CODE "
execute_process(COMMAND codesign --force --deep --sign - \"${APPS}\")
")
set(CPACK_GENERATOR DragNDrop)
set(CPACK_PACKAGE_FILE_NAME "Neogurt-${PROJECT_VERSION}-${CMAKE_HOST_SYSTEM_PROCESSOR}")
include(CPack)
endif()
endif()