-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
69 lines (61 loc) · 2.55 KB
/
CMakeLists.txt
File metadata and controls
69 lines (61 loc) · 2.55 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
cmake_minimum_required(VERSION 3.19)
project(ghostling C)
# Generate compile_commands.json for clangd/IDE support.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(FetchContent)
# --- Raylib ------------------------------------------------------------------
# Use a system-installed raylib if available, otherwise fetch from GitHub.
set(RAYLIB_VERSION 5.5)
find_package(raylib ${RAYLIB_VERSION} QUIET)
if (NOT raylib_FOUND)
FetchContent_Declare(
raylib
DOWNLOAD_EXTRACT_TIMESTAMP OFF
URL https://github.com/raysan5/raylib/archive/refs/tags/${RAYLIB_VERSION}.tar.gz
)
FetchContent_GetProperties(raylib)
if (NOT raylib_POPULATED)
set(FETCHCONTENT_QUIET NO)
FetchContent_MakeAvailable(raylib)
endif()
endif()
# --- libghostty-vt -----------------------------------------------------------
# Virtual terminal emulator library from Ghostty. Requires `zig` on PATH.
# The Ghostty CMakeLists.txt delegates to `zig build lib-vt` to produce the
# shared library. See https://ghostty.org/docs/install/build for the
# required Zig version.
FetchContent_Declare(ghostty
GIT_REPOSITORY https://github.com/ghostty-org/ghostty.git
GIT_TAG fdb6e3d2c8543e2e756b7e07f44372efbc0fba4b
)
FetchContent_MakeAvailable(ghostty)
# --- Embed font as a C header ------------------------------------------------
# Convert the TTF font into a C byte-array header so we don't rely on C23
# #embed (which GCC < 15 doesn't support).
set(FONT_INPUT "${CMAKE_SOURCE_DIR}/fonts/JetBrainsMono-Regular.ttf")
set(FONT_HEADER "${CMAKE_BINARY_DIR}/font_jetbrains_mono.h")
add_custom_command(
OUTPUT "${FONT_HEADER}"
COMMAND ${CMAKE_COMMAND}
-DINPUT=${FONT_INPUT}
-DOUTPUT=${FONT_HEADER}
-DARRAY_NAME=font_jetbrains_mono
-P ${CMAKE_SOURCE_DIR}/bin2header.cmake
DEPENDS "${FONT_INPUT}" "${CMAKE_SOURCE_DIR}/bin2header.cmake"
COMMENT "Generating font_jetbrains_mono.h"
)
# --- Our Project -------------------------------------------------------------
add_executable(${PROJECT_NAME} main.c "${FONT_HEADER}")
target_compile_features(${PROJECT_NAME} PRIVATE c_std_11)
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_BINARY_DIR}")
target_link_libraries(${PROJECT_NAME} raylib ghostty-vt)
# macOS requires these system frameworks for raylib's windowing/input/rendering.
if (APPLE)
target_link_libraries(${PROJECT_NAME} "-framework IOKit")
target_link_libraries(${PROJECT_NAME} "-framework Cocoa")
target_link_libraries(${PROJECT_NAME} "-framework OpenGL")
endif()
# Linux requires libutil for forkpty().
if (UNIX AND NOT APPLE)
target_link_libraries(${PROJECT_NAME} util)
endif()