-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
145 lines (120 loc) · 4.3 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
cmake_minimum_required(VERSION 3.12)
project(nibble VERSION 0.1
DESCRIPTION "A fantasy console designed to run on real hardware"
LANGUAGES CXX C)
# To create a debug build, uncomment this:
# set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "")
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_RELEASE "")
set(CMAKE_C_FLAGS_DEBUG "")
elseif(APPLE)
set(CMAKE_CXX_FLAGS "-pagezero_size 10000 -image_base 100000000")
else()
set(CMAKE_CXX_FLAGS "-rdynamic")
endif()
# Static only
set(BUILD_SHARED_LIBS OFF)
set(RTMIDI_BUILD_STATIC_LIBS ON)
set(PNG_SHARED OFF)
set(PNG_STATIC ON)
set(PNG_TESTS OFF)
set(LIBTYPE STATIC)
set(SDL_SHARED OFF)
set(SDL_STATIC ON)
set(FORCE_STATIC_VCRT ON)
#
# PART 1 - Dependencies
#
# zlib first since libpng depends on it
add_subdirectory(subprojects/zlib)
# adjust some details for libpng
set(ZLIB_LIBRARY zlibstatic)
set(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/subprojects/zlib)
set(SKIP_INSTALL_ALL TRUE)
add_subdirectory(subprojects/libpng)
add_subdirectory(subprojects/giflib)
add_subdirectory(subprojects/mp4)
add_subdirectory(subprojects/x264)
add_subdirectory(subprojects/rtmidi)
add_subdirectory(subprojects/sdl2)
find_library(LUAJIT NAMES lua51.lib libluajit.a HINTS subprojects/luajit/src)
#
# PART 2 - Nibble
#
# 1. Add the source files and headers
set(SOURCE_FILES src/main.cpp
src/getopt.c
src/devices/MidiController.cpp
src/devices/Keyboard.cpp
src/devices/Controller.cpp
src/devices/Mouse.cpp
src/devices/Audio.cpp
src/devices/GPU.cpp
src/kernel/VideoEncoder.cpp
src/kernel/TriangleWave.cpp
src/kernel/FMSynthesizer.cpp
src/kernel/Envelope.cpp
src/kernel/Wave.cpp
src/kernel/Channel.cpp
src/kernel/Process.cpp
src/kernel/Memory.cpp
src/kernel/filesystem.cpp
src/kernel/mmap/Binary.cpp
src/kernel/mmap/Image.cpp
src/kernel/SquareWave.cpp
src/kernel/Kernel.cpp
src/kernel/SawWave.cpp
include/devices/MidiController.hpp
include/devices/Keyboard.hpp
include/devices/Controller.hpp
include/devices/Mouse.hpp
include/devices/Audio.hpp
include/devices/GPU.hpp
include/kernel/VideoEncoder.hpp
include/kernel/TriangleWave.hpp
include/kernel/FMSynthesizer.hpp
include/kernel/Envelope.hpp
include/kernel/Wave.hpp
include/kernel/Channel.hpp
include/kernel/Process.hpp
include/kernel/Memory.hpp
include/kernel/filesystem.hpp
include/kernel/mmap/Binary.hpp
include/kernel/mmap/Image.hpp
include/kernel/SquareWave.hpp
include/kernel/Kernel.hpp
include/kernel/SawWave.hpp)
set(INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/include/
${CMAKE_SOURCE_DIR}/subprojects/sdl2/include/
${CMAKE_SOURCE_DIR}/subprojects/luajit/src/
${CMAKE_SOURCE_DIR}/subprojects/giflib/
${CMAKE_SOURCE_DIR}/subprojects/mp4/
${CMAKE_SOURCE_DIR}/subprojects/mp4/mp4v2/
${CMAKE_SOURCE_DIR}/subprojects/libpng/
${CMAKE_SOURCE_DIR}/subprojects/x264/
${ZLIB_INCLUDE_DIR})
# 2. Create an executable from the files
if(WIN32)
add_executable(nibble ${SOURCE_FILES})
else()
add_executable(nibble ${SOURCE_FILES})
endif()
# 3. Add include directories
target_include_directories(nibble PRIVATE ${INCLUDE_DIRS})
# 4. Link with the needed libraries
if(MSVC)
add_link_options("/MT")
endif()
target_link_libraries(nibble zlibstatic
png_static
giflib
rtmidi
SDL2-static
SDL2main
mp4
x264
${LUAJIT})