-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
143 lines (124 loc) · 4.03 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
cmake_minimum_required(VERSION 3.21)
project(sq68ux C)
add_compile_options(-U_FORTIFY_SOURCE -Werror -Wall -Wextra -Wpedantic)
if(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(USE_FLAGS "-s USE_SDL=2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ${USE_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 ${USE_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS
"${CMAKE_EXE_LINKER_FLAGS} ${USE_FLAGS} -s ALLOW_MEMORY_GROWTH=1 --preload-file ${CMAKE_SOURCE_DIR}/Q68_SMSQ.bin@./Q68_SMSQ.bin"
)
configure_file(q68_wrapper_sample.html q68.html COPYONLY)
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -Og")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb -Og")
find_package(SDL2 REQUIRED)
endif()
include_directories(
${CMAKE_CURRENT_LIST_DIR}
include/
Musashi/
args/src/
inih/
log.c/src/
external/
qlay/
uthash/src/
${SDL2_INCLUDE_DIRS})
find_package(Git)
add_custom_target(
SubmarineGitVersion
COMMAND
${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE} -D
INPUT_FILE=${CMAKE_CURRENT_SOURCE_DIR}/version.c.in -D
OUTPUT_FILE=${CMAKE_CURRENT_BINARY_DIR}/version.c -P
${CMAKE_CURRENT_SOURCE_DIR}/generate_version.cmake)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/version.c
PROPERTIES GENERATED TRUE)
add_custom_target(
Musashi
COMMAND
make m68kops.c
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Musashi/
)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/Musashi/m68kops.c
PROPERTIES GENERATED TRUE)
add_executable(
sq68ux
src/emulator_events.c
src/emulator_files.c
src/emulator_main.c
src/emulator_options.c
src/emulator_screen.c
src/q68_hardware.c
src/q68_hooks.c
src/q68_keyboard.c
src/q68_mainloop.c
src/q68_memory.c
src/q68_sd.c
external/sdl-ps2.c
args/src/args.c
inih/ini.c
log.c/src/log.c
Musashi/m68kcpu.c
Musashi/m68kops.c
Musashi/m68kdasm.c
Musashi/softfloat/softfloat.c
${CMAKE_CURRENT_BINARY_DIR}/version.c)
add_dependencies(sq68ux SubmarineGitVersion Musashi)
target_compile_options(sq68ux PRIVATE -DQ68_EMU -DEMU_STR="sq68ux" -Wall
-Wextra -Wpedantic -Werror
-DMUSASHI_CNF=\"emu68kconf.h\")
set_property(TARGET sq68ux PROPERTY C_STANDARD 17)
add_executable(
sqlay3
src/emulator_events.c
src/emulator_files.c
src/emulator_main.c
src/emulator_options.c
src/emulator_screen.c
src/qlay_disk.c
src/qlay_memory.c
src/qlay_hardware.c
src/qlay_hooks.c
src/qlay_io.c
src/qlay_keyboard.c
src/qlay_mainloop.c
src/qlay_trace.c
args/src/args.c
inih/ini.c
Musashi/m68kcpu.c
Musashi/m68kops.c
Musashi/m68kdasm.c
Musashi/softfloat/softfloat.c
${CMAKE_CURRENT_BINARY_DIR}/version.c)
add_dependencies(sqlay3 SubmarineGitVersion Musashi)
target_compile_options(sqlay3 PRIVATE -DQLAY_EMU -DEMU_STR="sqlay3" -Wall
-Wextra -Wpedantic -Werror
-DMUSASHI_CNF=\"emu68kconf.h\")
set_property(TARGET sqlay3 PROPERTY C_STANDARD 17)
# m68kdasm.c doesnt pass _FORTIFY_SOURCE=2
if(NOT ${CMAKE_C_COMPILER_ID} MATCHES "Clang")
set_source_files_properties(Musashi/m68kdasm.c
PROPERTIES COMPILE_FLAGS -Wno-format-overflow)
endif()
set_source_files_properties(args/src/args.c Musashi/m68kcpu.c
PROPERTIES COMPILE_FLAGS -Wno-pedantic)
set_source_files_properties(Musashi/m68kops.c
PROPERTIES COMPILE_FLAGS -Wno-unused-variable)
if(SDL2_LIBRARIES)
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(EMU_BUILD_LIBS
"-Wl,-Bstatic -L/usr/local/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -lpthread -Wl,-Bdynamic -lwsock32 -lwinmm -lsetupapi -limm32 -lversion -static-libgcc"
)
else()
set(EMU_BUILD_LIBS ${SDL2_LIBRARIES})
endif()
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
set(EMU_BUILD_LIBS ${SDL2_LIBRARIES})
else()
set(EMU_BUILD_LIBS "SDL2::SDL2")
endif()
target_link_libraries(sq68ux -lm ${EMU_BUILD_LIBS})
target_link_libraries(sqlay3 -lm ${EMU_BUILD_LIBS})
install(TARGETS sqlay3 DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/)