]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - CMakeLists.txt
items: move particle effects to CSQC for bandwidth and consistency
[xonotic/xonotic-data.pk3dir.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
2 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
3 project(xonotic-data ASM)
4
5 set(all qc-all)
6 add_custom_target(${all})
7
8 set(checks qc-checks)
9 add_custom_target(${checks})
10
11 if (gmqcc_BINARY_DIR)
12     set(compilerinfo "${gmqcc_BINARY_DIR}/gmqcc.h")
13     add_custom_command(
14             OUTPUT "${compilerinfo}"
15             DEPENDS "${gmqcc_BINARY_DIR}/gmqcc"
16             VERBATIM
17             COMMAND ${CMAKE_COMMAND} -E
18                 md5sum "${gmqcc_BINARY_DIR}/gmqcc" > "${compilerinfo}"
19             )
20     add_custom_target(qcc ALL
21             DEPENDS "${compilerinfo}"
22             )
23 endif ()
24
25 add_dependencies(${checks} data-check-cvars)
26 add_custom_target(data-check-cvars
27         COMMENT "checking cvars"
28         WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
29         VERBATIM COMMAND ${CMAKE_COMMAND} -E
30         env "CMAKE=1"
31         "${PROJECT_SOURCE_DIR}/check-cvars.sh"
32         )
33
34 add_dependencies(${checks} qc-genmod)
35 add_custom_target(qc-genmod
36         COMMENT "genmod.sh"
37         WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
38         VERBATIM COMMAND ./tools/genmod.sh
39         )
40
41 add_dependencies(${checks} qc-headerstyle)
42 add_custom_target(qc-headerstyle
43         COMMENT "headerstyle.sh"
44         WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
45         VERBATIM COMMAND ${CMAKE_COMMAND} -E
46         env "VERBOSE=0"
47         ./tools/headerstyle.sh
48         )
49
50 add_dependencies(${checks} qc-whitespace)
51 add_custom_target(qc-whitespace
52         COMMENT "whitespace.sh"
53         WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
54         VERBATIM COMMAND ./tools/whitespace.sh
55         )
56
57 function(prog name dir)
58     add_executable(${name} qcsrc/${dir}/progs.inc)
59     add_dependencies(${all} ${name})
60     add_dependencies(${name} ${checks})
61     add_dependencies(${name} qcc)
62     set_source_files_properties(qcsrc/${dir}/progs.inc PROPERTIES OBJECT_DEPENDS "${compilerinfo}")
63 endfunction()
64
65 function(set_prelude target prelude)
66     get_target_property(MY_PROJECT_SOURCES ${target} SOURCES)
67     foreach (source IN LISTS MY_PROJECT_SOURCES)
68         set_property(
69                 SOURCE ${source}
70                 APPEND PROPERTY COMPILE_FLAGS
71                 "-include ${prelude}"
72         )
73     endforeach ()
74 endfunction()
75
76 include_directories(qcsrc)
77
78 add_definitions(-DXONOTIC=1)
79 add_definitions(-DNDEBUG=1)
80 add_definitions(-DENABLE_EFFECTINFO=0)
81 add_definitions(-DENABLE_DEBUGDRAW=0)
82 add_definitions(-DENABLE_DEBUGTRACE=0)
83
84 if (DEFINED ENV{VERSION})
85     set(GIT_DESC "$ENV{VERSION}")
86 else ()
87     find_package(Git REQUIRED)
88     execute_process(
89             COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=~
90             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
91             OUTPUT_VARIABLE GIT_DESC
92             OUTPUT_STRIP_TRAILING_WHITESPACE
93     )
94 endif ()
95 add_definitions(-DWATERMARK=\"${GIT_DESC}\")
96
97 set_source_files_properties(
98         qcsrc/client/progs.inc
99         qcsrc/server/progs.inc
100         qcsrc/menu/progs.inc
101         PROPERTIES
102         LANGUAGE ASM
103         HEADER_FILE_ONLY FALSE
104 )
105
106 prog(csprogs client)
107 target_compile_definitions(csprogs PRIVATE -DGAMEQC -DCSQC)
108 # set_prelude(csprogs "${PROJECT_SOURCE_DIR}/qcsrc/lib/_all.inc")
109
110 prog(progs server)
111 target_compile_definitions(progs PRIVATE -DGAMEQC -DSVQC)
112
113 prog(menu menu)
114 target_compile_definitions(menu PRIVATE -DMENUQC)
115
116 function(copy prog)
117     add_custom_command(TARGET ${prog} POST_BUILD
118             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.dat" "${prog}.dat"
119             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.lno" "${prog}.lno"
120             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
121             VERBATIM)
122 endfunction()
123 copy(csprogs)
124 copy(progs)
125 copy(menu)
126
127 function(pack prog)
128     add_custom_target(${prog}.pk3 ALL
129             DEPENDS ${prog}-${GIT_DESC}.pk3
130             )
131     add_custom_command(OUTPUT ${prog}-${GIT_DESC}.pk3
132             DEPENDS ${prog}
133             COMMAND ${CMAKE_COMMAND} -E echo "https://xonotic.org" > "${prog}-${GIT_DESC}.txt"
134             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.dat" "${prog}-${GIT_DESC}.dat"
135             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.lno" "${prog}-${GIT_DESC}.lno"
136             COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${prog}-${GIT_DESC}.pk3" --format=zip
137             "${prog}-${GIT_DESC}.txt"
138             "${prog}-${GIT_DESC}.dat"
139             "${prog}-${GIT_DESC}.lno"
140             VERBATIM
141             )
142 endfunction()
143 pack(csprogs)