From 0b740fb801278d163504f0c0a9792c11bc0f024f Mon Sep 17 00:00:00 2001 From: TimePath Date: Sun, 20 Mar 2016 11:00:30 +1100 Subject: [PATCH] CMake: pk3, watermark --- CMakeLists.txt | 34 +++++++++++++++++++++++++++++++-- cmake/CMakeASMInformation.cmake | 12 +++++++++--- cmake/qcc.sh | 6 +++--- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a2008975e..767c90db6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,19 @@ cmake_minimum_required(VERSION 2.8.11) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) project(xonotic-data LANGUAGES ASM) -add_definitions(-DWATERMARK=\"12345\") -add_definitions(-DNDEBUG=1) include_directories(qcsrc) +add_definitions(-DNDEBUG=1) + +find_package(Git REQUIRED) +execute_process( + COMMAND ${GIT_EXECUTABLE} describe --tags --dirty=* + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_DESC + OUTPUT_STRIP_TRAILING_WHITESPACE +) +add_definitions(-DWATERMARK=\"${GIT_DESC}\") + set_source_files_properties( qcsrc/client/progs.inc qcsrc/server/progs.inc @@ -17,9 +26,30 @@ set_source_files_properties( add_executable(csprogs qcsrc/client/progs.inc) target_compile_definitions(csprogs PRIVATE -DCSQC) +add_dependencies(csprogs gmqcc) add_executable(progs qcsrc/server/progs.inc) target_compile_definitions(progs PRIVATE -DSVQC) +add_dependencies(progs gmqcc) add_executable(menu qcsrc/menu/progs.inc) target_compile_definitions(menu PRIVATE -DMENUQC) +add_dependencies(menu gmqcc) + +function(pack prog) + add_custom_target(${prog}.pk3 + DEPENDS ${prog}-${GIT_DESC}.pk3 + ) + add_custom_command(OUTPUT ${prog}-${GIT_DESC}.pk3 + DEPENDS ${prog} + COMMAND ${CMAKE_COMMAND} -E echo "http://xonotic.org" > "${prog}-${GIT_DESC}.txt" + COMMAND ${CMAKE_COMMAND} -E copy "$/${prog}.dat" "${prog}-${GIT_DESC}.dat" + COMMAND ${CMAKE_COMMAND} -E copy "$/${prog}.lno" "${prog}-${GIT_DESC}.lno" + COMMAND ${CMAKE_COMMAND} -E tar "cfv" "${prog}-${GIT_DESC}.pk3" --format=zip + "${prog}-${GIT_DESC}.txt" + "${prog}-${GIT_DESC}.dat" + "${prog}-${GIT_DESC}.lno" + VERBATIM + ) +endfunction() +pack(csprogs) diff --git a/cmake/CMakeASMInformation.cmake b/cmake/CMakeASMInformation.cmake index 8fd541b9b..e4e7bd923 100644 --- a/cmake/CMakeASMInformation.cmake +++ b/cmake/CMakeASMInformation.cmake @@ -1,6 +1,12 @@ -# TODO: -set(CMAKE_ASM_COMPILE_OBJECT " compile -DGMQCC ") -set(CMAKE_ASM_LINK_EXECUTABLE " link -o ") +if (${CMAKE_VERSION} VERSION_LESS "3.4") + set(_CMAKE_ASM_INCLUDES "") +else() + set(_CMAKE_ASM_INCLUDES "") +endif() +mark_as_advanced(_CMAKE_ASM_INCLUDES) + +set(CMAKE_ASM_COMPILE_OBJECT " compile -DGMQCC ${_CMAKE_ASM_INCLUDES} ") +set(CMAKE_ASM_LINK_EXECUTABLE "env CMAKE_EXECUTABLE_SUFFIX=${CMAKE_EXECUTABLE_SUFFIX} link -o ") set(CMAKE_INCLUDE_FLAG_ASM "-I") set(CMAKE_INCLUDE_FLAG_ASM_SEP "") diff --git a/cmake/qcc.sh b/cmake/qcc.sh index 0fbd8db12..2e8ea7062 100755 --- a/cmake/qcc.sh +++ b/cmake/qcc.sh @@ -1,9 +1,9 @@ #!/bin/bash -QCC=${QCC:-$(dirname "$0")/../../../gmqcc/gmqcc} +CPP=${CPP:-cpp} +QCC=${QCC:-$PWD/../../gmqcc/gmqcc${CMAKE_EXECUTABLE_SUFFIX}} case $1 in compile) - echo $@ - cpp ${@:3} | sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' > $2 + ${CPP} ${@:3} | sed 's/^#\(line\)\? \([[:digit:]]\+\) "\(.*\)".*/\n#pragma file(\3)\n#pragma line(\2)/g' > $2 ;; link) ${QCC} \ -- 2.39.2