-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
147 lines (113 loc) · 4.93 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
cmake_minimum_required (VERSION 2.6)
project (zxtk)
message(STATUS "Configuring zxtk...")
set (ZXTK_VERSION_MAJOR 0)
set (ZXTK_VERSION_MINOR 0)
set (ZXTK_VERSION_UPDATE 0)
set (ZXTK_TYPES_BYTE "std::uint8_t" CACHE STRING "The type of a byte. It is very unlikely you will want to change this (uint8_t)")
set (ZXTK_TYPES_WORD "std::uint16_t" CACHE STRING "The type of a word. It is very unlikely you will want to change this (uint16_t)")
set (ZXTK_TYPES_POINTER "std::uintptr_t" CACHE STRING "The type of an address (all memory, not z80) (uintptr_t)")
set (ZXTK_TYPES_CYCLE "std::uint32_t" CACHE STRING "The type of a cycle. (32bit: 20min, 64 bit: 150millenia) (uint32_t)")
set (INCLUDE_FILE "include.default.hpp" CACHE STRING "include.hpp file to use (is included everywhere) (include.default.hpp)")
set (LOAD_FILE "load.default.cpp" CACHE STRING "load.cpp file to use (load.default.cpp)")
set (CONFIGURE_FILE "configure.default.hpp" CACHE STRING "configure.hpp file to use (configure.default.hpp")
option(ZXTK_ENDIANNESS_CONST "Determine endianness of CPU at compile time (on)" TRUE)
option(ZXTK_CORRECT_TIMING "Time operations correctly. Without this, operations will be completed on the first T state (on)" TRUE)
option(ZXTK_Z80_FASTEST "This speeds up emulation max speed, possibly breaking some programs. Note that is forces off ZXTK_CORRECT_TIMING. (off)" FALSE)
option(ZXTK_MULTI_THREADS "This compiles zxtk with multiple threads, possibly speeding up emulation (on)" TRUE)
option(ZXTK_BUFFER "When multiple threads are enabled, this enables a memory buffer, increasing memory usage but allowing the z80 to run ahead of the display etc (on)" TRUE)
option(USE_SDL "Enable graphical display of emulation using SDL (on)" TRUE)
option(SDL2_STATIC "Link static build of SDL into the binaries" FALSE)
# At some point, I will probably want to make the SDL2_STATIC option only appear if SDL is enabled
option(STATIC "Build zxtk libraries as static libraries" FALSE)
option(GTEST_SHARED "Force building Google Test as a shared library" FALSE)
if (GTEST_SHARED)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
endif ()
option(COMPILE_TESTS "Compile tests" TRUE)
# This might seem a bit weird, but the chance of someone not wanting SDL at the moment is pretty low
set (ZXTK_USING_SDL_TRUE 0)
if (USE_SDL)
message(STATUS "Looking for SDL...")
set (ZXTK_USING_SDL_TRUE 1)
find_package(SDL2 REQUIRED)
link_directories(${SDL2_LIBRARY_DIRS})
message(STATUS "SDL found")
endif ()
set(ZXTK_ENDIANNESS_CONST_CFG 0)
if (ZXTK_ENDIANNESS_CONST)
set(ZXTK_ENDIANNESS_CONST_CFG 1)
endif ()
set(ZXTK_Z80_CORRECT_FLAGS_CFG 0)
if (ZXTK_Z80_CORRECT_FLAGS)
set(ZXTK_Z80_CORRECT_FLAGS_CFG 1)
endif ()
set(ZXTK_CORRECT_TIMING_CFG 0)
if (ZXTK_CORRECT_TIMING)
set(ZXTK_CORRECT_TIMING_CFG 1)
endif ()
set(ZXTK_Z80_FASTEST_CFG 0)
if (ZXTK_Z80_FASTEST)
set(ZXTK_Z80_FASTEST_CFG 1)
endif ()
set(ZXTK_MULTI_THREADS_CFG 0)
if (ZXTK_MULTI_THREADS)
set(ZXTK_MULTI_THREADS_CFG 1)
endif ()
set(ZXTK_BUFFER_CFG 0)
if (ZXTK_BUFFER)
set(ZXTK_BUFFER_CFG 1)
endif ()
set(ZXTK_VERSION "${ZXTK_VERSION_MAJOR}.${ZXTK_VERSION_MINOR}.${ZXTK_VERSION_UPDATE}")
configure_file (
"${PROJECT_SOURCE_DIR}/src/include/zxtk/misc/zxtk_config.hpp.in"
"${PROJECT_BINARY_DIR}/src/include/zxtk/misc/zxtk_config.hpp"
)
configure_file (
"${PROJECT_SOURCE_DIR}/src/include/zxtk/misc/zxtk_types.hpp.in"
"${PROJECT_BINARY_DIR}/src/include/zxtk/misc/zxtk_types.hpp"
)
configure_file (
"${PROJECT_SOURCE_DIR}/src/include/zxtk/misc/zxtk_info.hpp.in"
"${PROJECT_BINARY_DIR}/src/include/zxtk/misc/zxtk_info.hpp"
)
configure_file (
"${PROJECT_SOURCE_DIR}/src/include/zxtk/misc/zxtk_options.hpp.in"
"${PROJECT_BINARY_DIR}/src/include/zxtk/misc/zxtk_options.hpp"
)
configure_file (
"${PROJECT_SOURCE_DIR}/src/${CONFIGURE_FILE}"
"${PROJECT_BINARY_DIR}/src/include/zxtk/misc/zxtk_options.hpp"
)
include_directories("${PROJECT_BINARY_DIR}/src/include")
include_directories ("${PROJECT_SOURCE_DIR}/src/include")
if (STATIC)
add_library(load src/${LOAD_FILE})
add_library(memory src/utilities/buffer.cpp)
add_library(cpu src/modules/z80.cpp)
else ()
add_library(load SHARED src/${LOAD_FILE})
add_library(memory SHARED src/utilities/buffer.cpp)
add_library(cpu SHARED src/modules/z80.cpp)
endif ()
add_executable(zxtk src/zxtk.cpp)
target_link_libraries (zxtk memory load cpu)
install(TARGETS zxtk memory load cpu
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static
)
# TODO: Set ZXTK_TEST_SOURCES to everything in the test dir
if(COMPILE_TESTS)
set(ZXTK_TEST_SOURCES
src/tests/test.cpp
src/tests/test_buffer.cpp
src/tests/test_register_set.cpp
src/tests/test_cpu.cpp
src/tests/test_memory.cpp
)
add_subdirectory(src/lib/gtest)
include_directories(src/lib/gtest/googletest/include)
add_executable(tests ${ZXTK_TEST_SOURCES})
target_link_libraries(tests gtest memory)
endif ()