forked from angeld29/TF2003-qvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
131 lines (125 loc) · 4.47 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
# Проверка версии CMake
cmake_minimum_required( VERSION 3.4.0 )
# Если версия установленой программы ниже, то ошибка выполнения
add_subdirectory(tools/q3asm)
add_subdirectory(tools/q3lcc)
# Название проекта и проверка доступности компиляторя с++
project( qwprogs C )
#ADD_CUSTOM_TARGET(qvm
# Установка переменной со списком исходников
set ( DIR_SRC "src" )
set( SRC_NATIVE "${DIR_SRC}/g_syscalls.c")
set( SRC_VM_SYSCALL "g_syscalls.asm")
set( VM_LIB
"${DIR_SRC}/bg_lib.c"
"${DIR_SRC}/qmalloc.c"
)
set( SOURCE_LIB
"${DIR_SRC}/g_main.c"
"${DIR_SRC}/bot/ai.c"
"${DIR_SRC}/bot/ai-misc.c"
"${DIR_SRC}/bot/fighting.c"
"${DIR_SRC}/bot/move.c"
"${DIR_SRC}/bot/qw.c"
"${DIR_SRC}/bot/ui.c"
"${DIR_SRC}/bot/waypoint.c"
"${DIR_SRC}/actions.c"
"${DIR_SRC}/admin.c"
"${DIR_SRC}/admin_cmd.c"
"${DIR_SRC}/arena.c"
"${DIR_SRC}/buttons.c"
"${DIR_SRC}/clan.c"
"${DIR_SRC}/client.c"
"${DIR_SRC}/combat.c"
"${DIR_SRC}/coop.c"
"${DIR_SRC}/crc32.c"
"${DIR_SRC}/ctf.c"
"${DIR_SRC}/debug.c"
"${DIR_SRC}/demoman.c"
"${DIR_SRC}/doors.c"
"${DIR_SRC}/engineer.c"
"${DIR_SRC}/flare.c"
"${DIR_SRC}/g_cmd.c"
"${DIR_SRC}/g_mem.c"
"${DIR_SRC}/g_mod_command.c"
"${DIR_SRC}/g_spawn.c"
"${DIR_SRC}/g_tf_utils.c"
"${DIR_SRC}/g_utils.c"
"${DIR_SRC}/hook.c"
"${DIR_SRC}/items.c"
"${DIR_SRC}/mathlib.c"
"${DIR_SRC}/menu.c"
"${DIR_SRC}/misc.c"
"${DIR_SRC}/plats.c"
"${DIR_SRC}/player.c"
"${DIR_SRC}/pyro.c"
"${DIR_SRC}/q_shared.c"
"${DIR_SRC}/qmd5.c"
"${DIR_SRC}/scout.c"
"${DIR_SRC}/sentry.c"
"${DIR_SRC}/server.c"
"${DIR_SRC}/settings.c"
"${DIR_SRC}/sniper.c"
"${DIR_SRC}/spectate.c"
"${DIR_SRC}/spy.c"
"${DIR_SRC}/status.c"
"${DIR_SRC}/subs.c"
"${DIR_SRC}/tfort.c"
"${DIR_SRC}/tforthlp.c"
"${DIR_SRC}/tfortmap.c"
"${DIR_SRC}/tforttm.c"
"${DIR_SRC}/tg.c"
"${DIR_SRC}/triggers.c"
"${DIR_SRC}/tsoldier.c"
"${DIR_SRC}/version.c"
"${DIR_SRC}/vote.c"
"${DIR_SRC}/weapons.c"
"${DIR_SRC}/world.c"
"${DIR_SRC}/tf_set.c"
)
# Включение экспорта всех символов для создания динамической библиотеки
set ( CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON )
set ( VM_DIR "vm" )
set ( QVM_COMPILER "q3lcc" )
set ( QVM_LINKER "q3asm" )
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set ( QVM_LIST_FILE "${CMAKE_CURRENT_BINARY_DIR}/game.q3asm" )
set ( QVM_C_FLAGS -DQ3_VM -S -Wf-target=bytecode -Wf-g)
set ( INCFLAGS -I${CMAKE_CURRENT_SOURCE_DIR}/include )
add_custom_target(vmdir
COMMAND ${CMAKE_COMMAND} -E make_directory ${VM_DIR}
)
set ( SRC_VM ${SOURCE_LIB} ${VM_LIB} )
file(WRITE ${QVM_LIST_FILE} "-o qwprogs\n")
foreach(file ${SRC_VM} )
string(REGEX REPLACE "^${DIR_SRC}/" "" file_asm ${file})
get_filename_component (file_asm ${file_asm} NAME_WE)
string( CONCAT file_asm ${file_asm} ".asm")
#message(STATUS ${file_asm})
list( APPEND SOURCE_ASM ${file_asm})
#list( APPEND SOURCE_ASM ${VM_DIR}/${file_asm})
file(APPEND ${QVM_LIST_FILE} "${VM_DIR}/${file_asm}\n")
#add_custom_command(OUTPUT ${VM_DIR}/${file_asm}
#COMMAND ${QVM_COMPILER} ${QVM_C_FLAGS} ${INCFLAGS} "${CMAKE_CURRENT_SOURCE_DIR}/${file}" -o "${VM_DIR}/${file_asm}"
#DEPENDS vmdir ${file}
#)
add_custom_target(${file_asm}
COMMAND ${QVM_COMPILER} ${QVM_C_FLAGS} ${INCFLAGS} "${CMAKE_CURRENT_SOURCE_DIR}/${file}" -o "${VM_DIR}/${file_asm}"
DEPENDS vmdir
SOURCES ${file}
)
endforeach(file)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${DIR_SRC}/${SRC_VM_SYSCALL} ${VM_DIR}/${SRC_VM_SYSCALL} )
file(APPEND ${QVM_LIST_FILE} "${VM_DIR}/${SRC_VM_SYSCALL}\n")
message(STATUS ${QVM_LIST_FILE})
#add_custom_command(OUTPUT qwprogs.qvm
#COMMAND ${QVM_LINKER} -m -f ${QVM_LIST_FILE}
#DEPENDS ${SOURCE_ASM} )
add_custom_target(qvm
COMMAND ${QVM_LINKER} -m -f ${QVM_LIST_FILE}
DEPENDS ${SOURCE_ASM} )
#DEPENDS qwprogs.qvm )
# Создание динамической библиотеки с именем example
add_library( qwprogs SHARED ${SOURCE_LIB} ${SRC_NATIVE} )
target_include_directories ( qwprogs PRIVATE "include" )
set_target_properties(qwprogs PROPERTIES PREFIX "")