blob: 84de0c7a10dbc06788f21213b040f94260b21b31 (
plain)
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
|
include(CMakeParseArguments)
set(QVM_TOOLS_DIR ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/qvm_tools)
set(Q3CPP_BINARY ${QVM_TOOLS_DIR}/q3cpp )
set(Q3RCC_BINARY ${QVM_TOOLS_DIR}/q3rcc )
set(Q3LCC_BINARY ${QVM_TOOLS_DIR}/q3lcc )
set(Q3ASM_BINARY ${QVM_TOOLS_DIR}/q3asm )
set(QVM_DEPS ${Q3ASM_BINARY} ${Q3CPP_BINARY} ${Q3LCC_BINARY} ${Q3RCC_BINARY})
macro(QVM_COMPILE_ASM defs outfile infile)
add_custom_command(
OUTPUT ${outfile}
COMMAND ${Q3LCC_BINARY}
ARGS ${ADD_QVM_D} -o ${outfile} ${infile}
DEPENDS ${QVM_DEPS}
)
set_source_files_properties(${outfile} PROPERTIES GENERATED TRUE)
endmacro()
macro(ADD_QVM Name)
cmake_parse_arguments(ADD_QVM "" "" "" ${ARGN})
#message( "QVM: ${Name}" )
string(TOUPPER ${Name} UPNAME)
set(defs "-DVMS -D${UPNAME}")
#message( "DEFINITIONS ${defs}" )
foreach(srcfile ${ADD_QVM_UNPARSED_ARGUMENTS})
#message( "> ${srcfile}" )
get_filename_component(ext ${srcfile} EXT)
if ("${ext}" STREQUAL ".asm")
set(outfile ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile})
# Add asm files directly
list(APPEND srcs ${outfile})
endif()
if ("${ext}" STREQUAL ".c")
get_filename_component(outfile ${srcfile} NAME_WE)
set(outfile ${outfile}.asm)
# compile C code into asm
qvm_compile_asm(${defs} ${outfile} ${CMAKE_CURRENT_SOURCE_DIR}/${srcfile})
# add asm to list
list(APPEND srcs ${outfile})
endif()
if ("${ext}" STREQUAL ".h")
# XXX: Ignore headers??
endif()
endforeach()
#message("SOURCES <${srcs}>")
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${Name}.qvm
COMMAND ${Q3ASM_BINARY}
ARGS -o ${Name}.qvm ${srcs}
DEPENDS ${Q3ASM_BINARY} ${srcs}
)
add_custom_target(${Name}.qvm DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${Name}.qvm)
endmacro()
#
#============================================================
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QVM
REQUIRED_VARS Q3LCC_BINARY Q3ASM_BINARY
)
|