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)
6 add_custom_target(${all})
9 add_custom_target(${checks})
12 set(compilerinfo "${gmqcc_BINARY_DIR}/gmqcc.h")
14 OUTPUT "${compilerinfo}"
15 DEPENDS "${gmqcc_BINARY_DIR}/gmqcc"
17 COMMAND ${CMAKE_COMMAND} -E
18 md5sum "${gmqcc_BINARY_DIR}/gmqcc" > "${compilerinfo}"
20 add_custom_target(qcc ALL
21 DEPENDS "${compilerinfo}"
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
31 "${PROJECT_SOURCE_DIR}/check-cvars.sh"
34 add_dependencies(${checks} qc-genmod)
35 add_custom_target(qc-genmod
37 WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/qcsrc"
38 VERBATIM COMMAND ./tools/genmod.sh
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
47 ./tools/headerstyle.sh
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
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}")
65 function(set_prelude target prelude)
66 get_target_property(MY_PROJECT_SOURCES ${target} SOURCES)
67 foreach (source IN LISTS MY_PROJECT_SOURCES)
70 APPEND PROPERTY COMPILE_FLAGS
76 include_directories(qcsrc)
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)
84 if (DEFINED ENV{VERSION})
85 set(GIT_DESC "$ENV{VERSION}")
87 find_package(Git REQUIRED)
89 COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=~
90 WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
91 OUTPUT_VARIABLE GIT_DESC
92 OUTPUT_STRIP_TRAILING_WHITESPACE
95 add_definitions(-DWATERMARK=\"${GIT_DESC}\")
97 set_source_files_properties(
98 qcsrc/client/progs.inc
99 qcsrc/server/progs.inc
103 HEADER_FILE_ONLY FALSE
107 target_compile_definitions(csprogs PRIVATE -DGAMEQC -DCSQC)
108 # set_prelude(csprogs "${PROJECT_SOURCE_DIR}/qcsrc/lib/_all.inc")
111 target_compile_definitions(progs PRIVATE -DGAMEQC -DSVQC)
114 target_compile_definitions(menu PRIVATE -DMENUQC)
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}
128 add_custom_target(${prog}.pk3 ALL
129 DEPENDS ${prog}-${GIT_DESC}.pk3
131 add_custom_command(OUTPUT ${prog}-${GIT_DESC}.pk3
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"