-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
78 lines (59 loc) · 2.16 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
# Main configuration file
cmake_minimum_required(VERSION 3.25)
# Project root path.
set(MENIX_SRC ${CMAKE_CURRENT_SOURCE_DIR})
# Project version.
set(MENIX_RELEASE "0.0.1-dev")
string(TIMESTAMP MENIX_VERSION "%a %b %d %H:%M:%S UTC %Y" UTC)
# Get the current git commit hash.
execute_process(
COMMAND git log -1 --format=%h
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE GIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(MENIX_VERSION "${MENIX_VERSION} (${GIT_HASH})")
# Project license.
set(MENIX_LICENSE "LGPL")
# Target architecture, default to x86 if none given.
if(NOT DEFINED MENIX_ARCH)
set(MENIX_ARCH "x86_64")
endif()
# Common build system functionality.
set(MENIX_UTIL_PATH ${MENIX_SRC}/toolchain/util.cmake)
include(${MENIX_UTIL_PATH})
# Configuration file. Create one if it doesn't exist.
set(MENIX_CONFIG_SRC ${MENIX_SRC}/config.cmake)
if(NOT EXISTS ${MENIX_CONFIG_SRC})
set(MENIX_HAS_CONFIG FALSE)
file(WRITE ${MENIX_CONFIG_SRC} "# Build configuration\n\n")
else()
set(MENIX_HAS_CONFIG TRUE)
endif()
set(CMAKE_C_STANDARD 23)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_SYSTEM_NAME Generic)
project(menix LANGUAGES C CXX ASM)
# Generate a header file for the configuration.
set(MENIX_CONFIG ${MENIX_SRC}/include/generated/config.h CACHE INTERNAL "")
file(WRITE ${MENIX_CONFIG} "#pragma once\n// This file is automatically generated!\n\n")
add_executable(menix)
# Target for common compile and link flags
add_library(common INTERFACE)
add_library(common_kernel INTERFACE)
add_library(common_ko INTERFACE)
target_link_libraries(menix PUBLIC common common_kernel)
# Set toolchain.
include(${MENIX_SRC}/toolchain/arch/${MENIX_ARCH}.cmake)
include(${MENIX_SRC}/toolchain/arch/defaults.cmake)
include(${MENIX_SRC}/toolchain/compiler/${CMAKE_C_COMPILER_ID}.cmake)
include(${MENIX_SRC}/toolchain/compiler/common.cmake)
include(${MENIX_CONFIG_SRC})
# Global include directories.
include_directories(${MENIX_SRC}/include/)
include_directories(${MENIX_SRC}/include/klibc/)
include_directories(${MENIX_SRC}/kernel/arch/${MENIX_ARCH}/include/)
add_subdirectory(kernel)
add_subdirectory(modules)
# Link built-in modules
target_link_libraries(menix PUBLIC menix_builtin)