-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
61 lines (48 loc) · 1.58 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
cmake_minimum_required(VERSION 3.16)
project(FunnyOS C CXX ASM_NASM)
include(Config.cmake)
# CMake modules
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
include(Linking)
# Checks
if (NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles" AND NOT ${CMAKE_GENERATOR} STREQUAL "MinGW Makefiles")
message(FATAL_ERROR "Unsupported generator")
endif ()
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
message(FATAL_ERROR "Unsupported compiler")
endif ()
# Options
option(F_BUILD_TESTS "Should the testes be built?" ON)
# Tests
if (F_BUILD_TESTS)
find_package(GTest)
if (GTEST_FOUND)
enable_testing()
else()
message(WARNING "Testing will not be enabled as googletest was not found")
set(F_BUILD_TESTS OFF)
endif()
endif()
# Global variables
set(WARNING_OPTIONS
"-Wall -Wextra -Wno-unknown-pragmas -Wno-unused-function -Wno-unused-const-variable -Wno-c99-designator"
)
# C and C++ standards
set(CMAKE_CXX_STANDARD 20)
# Global flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_OPTIONS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_OPTIONS}")
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f elf64 -o <OBJECT> <SOURCE>")
# Default build type
if (CMAKE_BUILD_TYPE EQUAL "")
set(CMAKE_BUILD_TYPE "Release")
endif ()
# Global definitions
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DF_DEBUG)
endif ()
add_subdirectory("stdlib")
add_subdirectory("misc")
add_subdirectory("bootloader")
add_subdirectory("kernel")
add_subdirectory("targets")