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