-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
137 lines (121 loc) · 3.78 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
cmake_minimum_required(VERSION 3.9)
project(NESemu LANGUAGES CXX VERSION 0.0.1)
option(NESEMU_PEDANTIC_BUILD "Enable pedantic warnings during build" OFF)
if (CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Debug)
endif()
if (CPM_SOURCE_CACHE STREQUAL "")
message(WARNING "CPM_SOURCE_CACHE is empty, this will download locally all packages")
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/$<CONFIG>")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_INSTALL_RPATH "$ORIGIN")
set(CMAKE_BUILD_RPATH "$ORIGIN")
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# dependencies
include(CPM)
CPMAddPackage(
NAME mu
GIT_REPOSITORY https://github.com/mido3ds/mu.git
GIT_TAG 8174b6609e0cb3273aa329d5bbc2870fe6a513d0
GIT_SHALLOW TRUE
)
CPMAddPackage(
NAME sfml
GIT_REPOSITORY https://github.com/SFML/SFML
GIT_TAG 2.5.1
GIT_SHALLOW TRUE
)
CPMAddPackage(
NAME freetype
GIT_REPOSITORY https://github.com/freetype/freetype.git
GIT_TAG VER-2-11-1
GIT_SHALLOW TRUE
)
CPMAddPackage(
NAME Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v2.13.8
GIT_SHALLOW TRUE
)
CPMAddPackage(
NAME ImGui-SFML
GIT_REPOSITORY https://github.com/eliasdaler/imgui-sfml
GIT_TAG v2.5
GIT_SHALLOW TRUE
OPTIONS
"IMGUI_SFML_IMGUI_DEMO ON"
"IMGUI_SFML_FIND_SFML OFF"
"IMGUI_DIR ${CMAKE_SOURCE_DIR}/extern/imgui-1.88"
)
# AppleClang insists on compiling imgui-1.88 with old c++ standards
set_property(TARGET ImGui-SFML
PROPERTY
CXX_STANDARD 20
CMAKE_CXX_STANDARD_REQUIRED YES
CMAKE_CXX_EXTENSIONS NO
)
add_executable(nesemu)
## sources
target_sources(nesemu
PRIVATE
src/test/single_instructions.cpp
src/test/nestestlines.cpp
src/test/nestest.h
src/test/run_tests.cpp
src/test/nestest.cpp
src/Console.h
src/Console.cpp
src/ROM.cpp
src/instructions.cpp
src/PPU.cpp
src/CPU.cpp
src/RAM.cpp
src/main.cpp
)
## headers
target_include_directories(nesemu PRIVATE src/)
## dependecies
target_link_libraries(nesemu
PRIVATE
mido3ds::mu
sfml-window
sfml-graphics
sfml-audio
freetype
Catch2
ImGui-SFML::ImGui-SFML
$<$<PLATFORM_ID:Windows>:dbghelp>
)
set_property(TARGET nesemu
PROPERTY
CXX_STANDARD 20
CMAKE_CXX_STANDARD_REQUIRED YES
CMAKE_CXX_EXTENSIONS NO
)
target_compile_definitions(nesemu
PRIVATE
ASSETS_DIR="${CMAKE_SOURCE_DIR}/assets"
$<$<PLATFORM_ID:Windows>:UNICODE;_UNICODE>
$<$<PLATFORM_ID:Windows>:OS_WINDOWS=1>
$<$<PLATFORM_ID:Linux>:OS_LINUX=1>
$<$<PLATFORM_ID:Darwin>:OS_MACOS=1>
$<$<CXX_COMPILER_ID:Clang>:COMPILER_CLANG=1>
$<$<CXX_COMPILER_ID:AppleClang>:COMPILER_APPLE_CLANG=1>
$<$<CXX_COMPILER_ID:GNU>:COMPILER_GNU=1>
$<$<CXX_COMPILER_ID:MSVC>:COMPILER_MSVC=1>
$<$<CONFIG:DEBUG>:DEBUG>
)
# TODO: why is this? maybe because of nestestlines.cpp? if so, then i have to remove it
# target_compile_options(nesemu PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/bigobj>)
if (${NESEMU_PEDANTIC_BUILD})
target_compile_options(nesemu
PRIVATE
$<$<CXX_COMPILER_ID:MSVC>:/W4 /NODEFAULTLIB:library>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Wextra -pedantic -Wno-nested-anon-types>
)
endif()