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