-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
66 lines (49 loc) · 2.45 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
###############################################################################
# Primary CMakeLists for the kush-os project.
#
# Automatically builds kernel and userland components.
###############################################################################
cmake_minimum_required(VERSION 3.7 FATAL_ERROR)
project(kush VERSION 0.1 LANGUAGES ASM C CXX)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
### required modules
include(ExternalProject)
##### Sysroot directory: we install libraries and so forth there
set(SYSROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/../sysroot CACHE FILEPATH "Sysroot directory" FORCE)
message("Sysroot at ${SYSROOT_DIR}")
set(CMAKE_INSTALL_PREFIX ${SYSROOT_DIR})
set(CMAKE_INSTALL_INCLUDEDIR "usr/include")
##### Version
include(GetGitRevisionDescription)
git_describe(VERSION --tags --dirty=-d)
get_git_head_revision(GIT_REFSPEC GIT_HASH)
string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" VERSION_MAJOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${VERSION}")
string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" VERSION_SHA1 "${VERSION}")
set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
execute_process(COMMAND git describe --tags --dirty=d OUTPUT_VARIABLE VERSION_TAG OUTPUT_STRIP_TRAILING_WHITESPACE)
##### Options for what to be compiled
option(BUILD_KERNEL "Build the kernel" ON)
option(BUILD_USER_LIBS "Build userspace libraries" ON)
option(BUILD_SYSTEM_SERVERS "Build core system servers" ON)
##### General defines
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
#set(CMAKE_VERBOSE_MAKEFILE ON)
# configure warnings
add_compile_options(-Wall -Wno-format -Wmissing-declarations -Wformat=2 -fdiagnostics-color=always -ftls-model=initial-exec -Wundef -Wcast-qual -Wwrite-strings)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Werror -Wimplicit-fallthrough -Wno-deprecated-copy -Wno-address-of-packed-member -Wno-expansion-to-defined -Wno-undef)
add_compile_options(-Wno-unused-private-field)
endif()
####################
##### Use cross toolchain for all targets below
##### Specify options for kernel, free-standing userspace components
add_compile_options(-g1 -fstack-protector-strong -Wundef -Wcast-qual -Wwrite-strings)
##### Kernel
if(BUILD_KERNEL)
add_subdirectory(kernel)
endif()
##### Userspace
add_subdirectory(user)