This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
161 lines (127 loc) · 3.81 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#############
## General ##
#############
cmake_minimum_required (VERSION 3.9)
project (MIPS32 CXX)
#include_directories(include third-party)
set(MIPS32_VERSION_MAJOR 0)
set(MIPS32_VERSION_MINOR 5)
set(MIPS32_VERSION_PATCH 0)
#############
## Library ##
#############
add_library(fs-mips32 SHARED
src/ram.cpp
src/ram_io.cpp
src/mmu.cpp
src/cp0.cpp
src/cp1.cpp
src/cpu.cpp
src/machine_inspector.cpp
src/machine.cpp
)
###########
## Tests ##
###########
add_executable(Tests
test/test_main.cpp
src/machine_inspector.cpp
# RAM
test/test_ram.cpp
src/ram.cpp
# Coprocessor 1
test/test_cp1.cpp
src/cp1.cpp
# CPU
test/test_cpu.cpp
src/cpu.cpp
src/ram_io.cpp
src/cp0.cpp
src/mmu.cpp
test/helpers/Terminal.cpp
test/helpers/FileManager.cpp
# Machine Inspector
test/test_save_restore_state.cpp
# RAMIO
test/test_ram_io.cpp
# Example Programs - Kernel
test/test_example_programs_kernel.cpp
)
############
## GLOBAL ##
############
target_compile_features(Tests PRIVATE cxx_std_17)
target_include_directories(Tests PRIVATE include third-party test/helpers)
target_compile_features(fs-mips32 PRIVATE cxx_std_17)
target_include_directories(fs-mips32 PRIVATE include)
if (CMAKE_BUILD_TYPE STREQUAL "Coverage")
target_compile_options(Tests PRIVATE -g -O0 --coverage -w)
target_link_libraries(Tests PRIVATE -lgcov --coverage)
else() # Normal build
if(MSVC)
target_compile_options(Tests PRIVATE /W3 /fp:strict /wd4146 /wd4267 /permissive-)
target_compile_definitions(Tests PRIVATE "-D_CRT_SECURE_NO_WARNINGS")
target_compile_options(fs-mips32 PRIVATE /W3 /fp:strict /wd4146 /wd4267 /permissive-)
target_compile_definitions(fs-mips32 PRIVATE "-D_CRT_SECURE_NO_WARNINGS")
else() # GCC - Clang
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
target_compile_options(Tests PRIVATE
-Wall -Wextra
-Wno-logical-op-parentheses
-Wno-bitwise-op-parentheses
-Wno-implicit-fallthrough
-Wno-dollar-in-identifier-extension
)
target_compile_options(fs-mips32 PRIVATE
-Wall -Wextra
-Wno-logical-op-parentheses
-Wno-bitwise-op-parentheses
-Wno-implicit-fallthrough
-Wno-dollar-in-identifier-extension
)
else() # GCC
target_compile_options(Tests PRIVATE
-Wall -Wextra
-Wno-parentheses
-Wimplicit-fallthrough=0
-Wno-unused-but-set-variable
)
target_compile_options(fs-mips32 PRIVATE
-Wall -Wextra
-Wno-parentheses
-Wimplicit-fallthrough=0
-Wno-unused-but-set-variable
)
endif()
# x86 build
target_compile_options(Tests PRIVATE "$<$<STREQUAL:${ARCH},x86>:-m32>")
target_link_libraries(Tests PRIVATE "$<$<STREQUAL:${ARCH},x86>:-m32>")
target_compile_options(fs-mips32 PRIVATE "$<$<STREQUAL:${ARCH},x86>:-m32>")
target_link_libraries(fs-mips32 PRIVATE "$<$<STREQUAL:${ARCH},x86>:-m32>")
# x86_64 build
target_compile_options(Tests PRIVATE "$<$<STREQUAL:${ARCH},x64>:-m64>")
target_link_libraries(Tests PRIVATE "$<$<STREQUAL:${ARCH},x64>:-m64>")
target_compile_options(fs-mips32 PRIVATE "$<$<STREQUAL:${ARCH},x64>:-m64>")
target_link_libraries(fs-mips32 PRIVATE "$<$<STREQUAL:${ARCH},x64>:-m64>")
# Shared flags between GCC and Clang
target_compile_options(Tests PRIVATE
-mfpmath=sse -msse2
-pedantic
-Wno-unknown-pragmas
-Wno-missing-braces
-Wno-unused-variable
-Wno-sign-compare
)
target_compile_options(fs-mips32 PRIVATE
-mfpmath=sse -msse2
-pedantic
-Wno-unknown-pragmas
-Wno-missing-braces
-Wno-unused-variable
-Wno-sign-compare
)
endif() # GCC - Clang
endif() # Debug|Release build
include(CTest)
enable_testing()
add_test(NAME AllTests COMMAND Tests)