]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - CMakeLists.txt
Use a proper namespace for many scoreboard variables
[xonotic/xonotic-data.pk3dir.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8.11)
2 list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
3 project(xonotic-data LANGUAGES ASM)
4
5 include_directories(qcsrc)
6
7 add_definitions(-DXONOTIC=1)
8 add_definitions(-DNDEBUG=1)
9
10 find_package(Git REQUIRED)
11 execute_process(
12         COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=~
13         WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
14         OUTPUT_VARIABLE GIT_DESC
15         OUTPUT_STRIP_TRAILING_WHITESPACE
16 )
17 add_definitions(-DWATERMARK=\"${GIT_DESC}\")
18
19 set_source_files_properties(
20         qcsrc/client/progs.inc
21         qcsrc/server/progs.inc
22         qcsrc/menu/progs.inc
23         PROPERTIES
24         LANGUAGE ASM
25         HEADER_FILE_ONLY FALSE
26 )
27
28 add_executable(csprogs qcsrc/client/progs.inc)
29 target_compile_definitions(csprogs PRIVATE -DCSQC)
30 add_dependencies(csprogs gmqcc)
31
32 add_executable(progs qcsrc/server/progs.inc)
33 target_compile_definitions(progs PRIVATE -DSVQC)
34 add_dependencies(progs gmqcc)
35
36 add_executable(menu qcsrc/menu/progs.inc)
37 target_compile_definitions(menu PRIVATE -DMENUQC)
38 add_dependencies(menu gmqcc)
39
40 function(set_prelude target prelude)
41     get_target_property(MY_PROJECT_SOURCES target SOURCES)
42     foreach (source IN LISTS MY_PROJECT_SOURCES)
43         set_property(
44                 SOURCE ${source}
45                 APPEND PROPERTY COMPILE_FLAGS
46                 "-include ${PROJECT_SOURCE_DIR}/${prelude}"
47         )
48     endforeach ()
49 endfunction()
50 # set_prelude(csprogs qcsrc/lib/_all.inc)
51
52 function(copy prog)
53     add_custom_command(TARGET ${prog} POST_BUILD
54             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.dat" "${prog}.dat"
55             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.lno" "${prog}.lno"
56             WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
57             VERBATIM)
58 endfunction()
59 copy(csprogs)
60 copy(progs)
61 copy(menu)
62
63 function(pack prog)
64     add_custom_target(${prog}.pk3
65             DEPENDS ${prog}-${GIT_DESC}.pk3
66             )
67     add_custom_command(OUTPUT ${prog}-${GIT_DESC}.pk3
68             DEPENDS ${prog}
69             COMMAND ${CMAKE_COMMAND} -E echo "http://xonotic.org" > "${prog}-${GIT_DESC}.txt"
70             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.dat" "${prog}-${GIT_DESC}.dat"
71             COMMAND ${CMAKE_COMMAND} -E copy "$<TARGET_FILE_DIR:${prog}>/${prog}.lno" "${prog}-${GIT_DESC}.lno"
72             COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${prog}-${GIT_DESC}.pk3" --format=zip
73             "${prog}-${GIT_DESC}.txt"
74             "${prog}-${GIT_DESC}.dat"
75             "${prog}-${GIT_DESC}.lno"
76             VERBATIM
77             )
78 endfunction()
79 pack(csprogs)