-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
103 lines (84 loc) · 2.94 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
cmake_minimum_required(VERSION 3.27)
project(crescent CXX ASM)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY bin)
if(BUILD_APPS)
add_subdirectory(libs)
add_subdirectory(apps)
if(NOT BUILD_EVERYTHING)
return()
endif()
endif()
set(ARCH "x86_64" CACHE STRING "Architecture to compile for")
include(qacpi/lib.cmake)
add_executable(crescent
src/main.cpp
)
target_include_directories(crescent PRIVATE
src
src/std
include
)
target_compile_options(crescent PRIVATE
-Wall -Wextra -Werror=switch -Werror=return-type -Werror=unused-result
-nostdinc++ -fno-exceptions -fno-threadsafe-statics -fno-rtti -fsized-deallocation
-ffreestanding -fno-strict-aliasing -Wframe-larger-than=4096 -fno-eliminate-unused-debug-types
-Wno-invalid-offsetof -Wno-unused-parameter -Wno-unused-const-variable
)
if(NOT ARCH STREQUAL "user")
target_compile_options(crescent PRIVATE
-mgeneral-regs-only -fno-stack-protector
-fno-omit-frame-pointer -mno-red-zone
)
target_link_options(crescent PRIVATE
-static -nostdlib -Wl,--fatal-warnings
-Wl,--export-dynamic -Wl,--build-id=none
)
endif()
add_subdirectory(src)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(crescent PRIVATE -Wno-unused-command-line-argument)
endif()
if(ARCH STREQUAL "x86_64")
target_compile_options(crescent PRIVATE -fPIE)
target_compile_definitions(crescent PRIVATE ARCH_X86_64)
target_link_options(crescent PRIVATE -T ${PROJECT_SOURCE_DIR}/lds/x86_64.ld -static-pie)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(crescent PRIVATE -fsanitize=undefined -fsanitize-minimal-runtime)
endif()
target_link_libraries(crescent PRIVATE qacpi::qacpi qacpi::events)
elseif(ARCH STREQUAL "aarch64")
target_compile_options(crescent PRIVATE -fno-PIE -mno-unaligned-access)
target_link_options(crescent PRIVATE -T ${PROJECT_SOURCE_DIR}/lds/aarch64.ld)
target_compile_definitions(crescent PRIVATE ARCH_AARCH64)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(crescent PRIVATE -fsanitize=undefined -fsanitize-minimal-runtime)
endif()
include(cmake/image_aarch64.cmake)
elseif(ARCH STREQUAL "user")
target_compile_options(crescent PRIVATE -fPIE -fsanitize=undefined,address)
target_link_options(crescent PRIVATE -fsanitize=undefined,address)
target_compile_definitions(crescent PRIVATE ARCH_USER)
include(cmake/image_user.cmake)
else()
message(FATAL_ERROR "Unsupported architecture ${ARCH}")
endif()
include(CMakeOptions.cmake)
target_sources(crescent PUBLIC FILE_SET HEADERS
BASE_DIRS include
FILES
include/crescent/aarch64/arch_syscall.h
include/crescent/x86/arch_syscall.h
include/crescent/devlink.h
include/crescent/event.h
include/crescent/evm.h
include/crescent/socket.h
include/crescent/syscall.h
include/crescent/syscalls.h
include/crescent/time.h
)
install(FILES limine.conf fonts/Tamsyn8x16r.psf DESTINATION "crescent")
install(TARGETS crescent FILE_SET HEADERS
RUNTIME DESTINATION "crescent"
)