-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
75 lines (60 loc) · 2.04 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
# Detect XTChain toolchain
cmake_minimum_required(VERSION 3.19.0)
if(NOT CMAKE_VERSION MATCHES "XTC")
message(FATAL_ERROR "XTChain not detected or corrupted!")
endif()
# Lowercase target architecture
string(TOLOWER ${ARCH} ARCH)
# Validate and set architectures specific definitions
if(ARCH STREQUAL "i686")
add_definitions(-D__i386__ -D__i686__)
elseif(ARCH STREQUAL "amd64")
add_definitions(-D__amd64__ -D__x86_64__)
else()
message(FATAL_ERROR "Unknown target architecture (${ARCH}) set!")
endif()
# Print target architecture
message("-- Target architecture: ${ARCH}")
# Set the build type
if(NOT BUILD_TYPE)
set(BUILD_TYPE DEBUG)
endif()
string(TOUPPER ${BUILD_TYPE} BUILD_TYPE)
# Set build type specific definitions
if(BUILD_TYPE STREQUAL "DEBUG")
add_definitions(-DDBG=1)
set(CMAKE_BUILD_TYPE DEBUG)
else()
set(BUILD_TYPE RELEASE)
set(CMAKE_BUILD_TYPE NONE)
endif()
# Print build type
message("-- Target build type: ${BUILD_TYPE}")
# Set toolchain file
set(CMAKE_TOOLCHAIN_FILE "sdk/cmake/toolchain.cmake")
# Set project name
project(EXECTOS)
# Load all the CMake SDK
include(sdk/cmake/baseaddress/${ARCH}.cmake)
include(sdk/cmake/emulation.cmake)
include(sdk/cmake/functions.cmake)
include(sdk/cmake/version.cmake)
include(sdk/cmake/xtchain.cmake)
# Enable compilers
enable_language(ASM C CXX)
# Add project specific definitions
add_definitions(-D__XTOS__)
add_definitions(-DXTOS_SOURCE_DIR="${EXECTOS_SOURCE_DIR}")
add_definitions(-DXTOS_BINARY_DIR="${EXECTOS_BINARY_DIR}")
# Set libraries target directory
set(LIBRARY_OUTPUT_PATH ${EXECTOS_BINARY_DIR}/output/library CACHE PATH "Build directory" FORCE)
# Compute __FILE__ definition
file(RELATIVE_PATH _PATH_PREFIX ${EXECTOS_BINARY_DIR} ${EXECTOS_SOURCE_DIR})
add_compiler_flags(-D__RELFILE__="&__FILE__[__FILE__[0] == '.' ? sizeof \\\"${_PATH_PREFIX}\\\" - 1 : sizeof XTOS_SOURCE_DIR]")
# Set the virtual disk image size (in MiB)
set_disk_image_size(32)
# Build all subprojects
add_subdirectory(bootdata)
add_subdirectory(drivers)
add_subdirectory(xtldr)
add_subdirectory(xtoskrnl)