1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-21 17:17:06 +02:00

Fix rebuilding everything on HEAD change

This commit is contained in:
Vadim Markovtsev 2016-10-23 16:56:53 +02:00
parent d0beb27197
commit da1c9cf249
15 changed files with 235 additions and 71 deletions

View File

@ -1,16 +1,13 @@
project(battleAI)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(battleAI_SRCS
StdInc.cpp
BattleAI.cpp
main.cpp
${CMAKE_BINARY_DIR}/Version.cpp
BattleAI.cpp
main.cpp
)
add_library(BattleAI SHARED ${battleAI_SRCS})

View File

@ -1,15 +1,12 @@
project(emptyAI)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(emptyAI_SRCS
CEmptyAI.cpp
exp_funcs.cpp
${CMAKE_BINARY_DIR}/Version.cpp
CEmptyAI.cpp
exp_funcs.cpp
)
add_library(EmptyAI SHARED ${emptyAI_SRCS})

View File

@ -1,14 +1,11 @@
project(stupidAI)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(stupidAI_SRCS
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
StupidAI.cpp
main.cpp
)

View File

@ -1,23 +1,21 @@
project(VCAI)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
if (FL_FOUND)
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib ${FL_INCLUDE_DIRS})
include_directories(${FL_INCLUDE_DIRS})
else()
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib ${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
include_directories(${CMAKE_HOME_DIRECTORY}/AI/FuzzyLite/fuzzylite)
endif()
include_directories(${Boost_INCLUDE_DIRS} ${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
set(VCAI_SRCS
StdInc.cpp
VCAI.cpp
Goals.cpp
AIUtility.cpp
main.cpp
Fuzzy.cpp
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
VCAI.cpp
Goals.cpp
AIUtility.cpp
main.cpp
Fuzzy.cpp
)
add_library(VCAI SHARED ${VCAI_SRCS})

View File

@ -341,3 +341,7 @@ else()
endif()
INCLUDE(CPack)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Version.cpp.in" "${CMAKE_BINARY_DIR}/Version.cpp" @ONLY)

6
Version.cpp.in Normal file
View File

@ -0,0 +1,6 @@
#include "Version.h"
namespace GameConstants
{
const char GIT_SHA1[] = "@GIT_SHA1@";
}

4
Version.h Normal file
View File

@ -0,0 +1,4 @@
namespace GameConstants
{
extern const char GIT_SHA1[];
}

View File

@ -1,16 +1,13 @@
project(vcmiclient)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
include_directories(${SDL_INCLUDE_DIR} ${SDLIMAGE_INCLUDE_DIR} ${SDLMIXER_INCLUDE_DIR} ${SDLTTF_INCLUDE_DIR})
include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS})
set(client_SRCS
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
../CCallback.cpp
battle/CBattleInterface.cpp

View File

@ -0,0 +1,130 @@
# - Returns a version string from Git
#
# These functions force a re-configure on each git commit so that you can
# trust the values of the variables in your build system.
#
# get_git_head_revision(<refspecvar> <hashvar> [<additional arguments to git describe> ...])
#
# Returns the refspec and sha hash of the current head revision
#
# git_describe(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe on the source tree, and adjusting
# the output so that it tests false if an error occurs.
#
# git_get_exact_tag(<var> [<additional arguments to git describe> ...])
#
# Returns the results of git describe --exact-match on the source tree,
# and adjusting the output so that it tests false if there was no exact
# matching tag.
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
if(__get_git_revision_description)
return()
endif()
set(__get_git_revision_description YES)
# We must run the following at "include" time, not at function call time,
# to find the path to this module rather than the path to a calling list file
get_filename_component(_gitdescmoddir ${CMAKE_CURRENT_LIST_FILE} PATH)
function(get_git_head_revision _refspecvar _hashvar)
set(GIT_PARENT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
while(NOT EXISTS "${GIT_DIR}") # .git dir not found, search parent directories
set(GIT_PREVIOUS_PARENT "${GIT_PARENT_DIR}")
get_filename_component(GIT_PARENT_DIR ${GIT_PARENT_DIR} PATH)
if(GIT_PARENT_DIR STREQUAL GIT_PREVIOUS_PARENT)
# We have reached the root directory, we are not in git
set(${_refspecvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
set(${_hashvar} "GITDIR-NOTFOUND" PARENT_SCOPE)
return()
endif()
set(GIT_DIR "${GIT_PARENT_DIR}/.git")
endwhile()
# check if this is a submodule
if(NOT IS_DIRECTORY ${GIT_DIR})
file(READ ${GIT_DIR} submodule)
string(REGEX REPLACE "gitdir: (.*)\n$" "\\1" GIT_DIR_RELATIVE ${submodule})
get_filename_component(SUBMODULE_DIR ${GIT_DIR} PATH)
get_filename_component(GIT_DIR ${SUBMODULE_DIR}/${GIT_DIR_RELATIVE} ABSOLUTE)
endif()
set(GIT_DATA "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/git-data")
if(NOT EXISTS "${GIT_DATA}")
file(MAKE_DIRECTORY "${GIT_DATA}")
endif()
if(NOT EXISTS "${GIT_DIR}/HEAD")
return()
endif()
set(HEAD_FILE "${GIT_DATA}/HEAD")
configure_file("${GIT_DIR}/HEAD" "${HEAD_FILE}" COPYONLY)
configure_file("${_gitdescmoddir}/GetGitRevisionDescription.cmake.in"
"${GIT_DATA}/grabRef.cmake"
@ONLY)
include("${GIT_DATA}/grabRef.cmake")
set(${_refspecvar} "${HEAD_REF}" PARENT_SCOPE)
set(${_hashvar} "${HEAD_HASH}" PARENT_SCOPE)
endfunction()
function(git_describe _var)
if(NOT GIT_FOUND)
find_package(Git QUIET)
endif()
get_git_head_revision(refspec hash)
if(NOT GIT_FOUND)
set(${_var} "GIT-NOTFOUND" PARENT_SCOPE)
return()
endif()
if(NOT hash)
set(${_var} "HEAD-HASH-NOTFOUND" PARENT_SCOPE)
return()
endif()
# TODO sanitize
#if((${ARGN}" MATCHES "&&") OR
# (ARGN MATCHES "||") OR
# (ARGN MATCHES "\\;"))
# message("Please report the following error to the project!")
# message(FATAL_ERROR "Looks like someone's doing something nefarious with git_describe! Passed arguments ${ARGN}")
#endif()
#message(STATUS "Arguments to execute_process: ${ARGN}")
execute_process(COMMAND
"${GIT_EXECUTABLE}"
describe
${hash}
${ARGN}
WORKING_DIRECTORY
"${CMAKE_CURRENT_SOURCE_DIR}"
RESULT_VARIABLE
res
OUTPUT_VARIABLE
out
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT res EQUAL 0)
set(out "${out}-${res}-NOTFOUND")
endif()
set(${_var} "${out}" PARENT_SCOPE)
endfunction()
function(git_get_exact_tag _var)
git_describe(out --exact-match ${ARGN})
set(${_var} "${out}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,41 @@
#
# Internal file for GetGitRevisionDescription.cmake
#
# Requires CMake 2.6 or newer (uses the 'function' command)
#
# Original Author:
# 2009-2010 Ryan Pavlik <rpavlik@iastate.edu> <abiryan@ryand.net>
# http://academic.cleardefinition.com
# Iowa State University HCI Graduate Program/VRAC
#
# Copyright Iowa State University 2009-2010.
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
set(HEAD_HASH)
file(READ "@HEAD_FILE@" HEAD_CONTENTS LIMIT 1024)
string(STRIP "${HEAD_CONTENTS}" HEAD_CONTENTS)
if(HEAD_CONTENTS MATCHES "ref")
# named branch
string(REPLACE "ref: " "" HEAD_REF "${HEAD_CONTENTS}")
if(EXISTS "@GIT_DIR@/${HEAD_REF}")
configure_file("@GIT_DIR@/${HEAD_REF}" "@GIT_DATA@/head-ref" COPYONLY)
else()
configure_file("@GIT_DIR@/packed-refs" "@GIT_DATA@/packed-refs" COPYONLY)
file(READ "@GIT_DATA@/packed-refs" PACKED_REFS)
if(${PACKED_REFS} MATCHES "([0-9a-z]*) ${HEAD_REF}")
set(HEAD_HASH "${CMAKE_MATCH_1}")
endif()
endif()
else()
# detached HEAD
configure_file("@GIT_DIR@/HEAD" "@GIT_DATA@/head-ref" COPYONLY)
endif()
if(NOT HEAD_HASH)
file(READ "@GIT_DATA@/head-ref" HEAD_HASH LIMIT 1024)
string(STRIP "${HEAD_HASH}" HEAD_HASH)
endif()

View File

@ -6,34 +6,35 @@ include_directories(${ZLIB_INCLUDE_DIR} ${Boost_INCLUDE_DIRS} ${Qt5Widgets_INCLU
include_directories(${SDL_INCLUDE_DIR})
set(launcher_modmanager_SRCS
modManager/cdownloadmanager_moc.cpp
modManager/cmodlist.cpp
modManager/cmodlistmodel_moc.cpp
modManager/cmodlistview_moc.cpp
modManager/cmodmanager.cpp
modManager/imageviewer_moc.cpp
modManager/cdownloadmanager_moc.cpp
modManager/cmodlist.cpp
modManager/cmodlistmodel_moc.cpp
modManager/cmodlistview_moc.cpp
modManager/cmodmanager.cpp
modManager/imageviewer_moc.cpp
)
set(launcher_settingsview_SRCS
settingsView/csettingsview_moc.cpp
settingsView/csettingsview_moc.cpp
)
set(launcher_SRCS
StdInc.cpp
${launcher_modmanager_SRCS}
${launcher_settingsview_SRCS}
main.cpp
mainwindow_moc.cpp
launcherdirs.cpp
jsonutils.cpp
sdldisplayquery.cpp
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
${launcher_modmanager_SRCS}
${launcher_settingsview_SRCS}
main.cpp
mainwindow_moc.cpp
launcherdirs.cpp
jsonutils.cpp
sdldisplayquery.cpp
)
set(launcher_FORMS
modManager/cmodlistview_moc.ui
modManager/imageviewer_moc.ui
settingsView/csettingsview_moc.ui
mainwindow_moc.ui
modManager/cmodlistview_moc.ui
modManager/imageviewer_moc.ui
settingsView/csettingsview_moc.ui
mainwindow_moc.ui
)
# Tell CMake to run moc when necessary:

View File

@ -1,15 +1,12 @@
project(libvcmi)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/lib)
include_directories(${Boost_INCLUDE_DIRS} ${SDL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR})
set(lib_SRCS
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
filesystem/AdapterLoaders.cpp
filesystem/CCompressedStream.cpp
@ -65,11 +62,11 @@ set(lib_SRCS
spells/CSpellHandler.cpp
spells/ISpellMechanics.cpp
spells/AdventureSpellMechanics.cpp
spells/BattleSpellMechanics.cpp
spells/CreatureSpellMechanics.cpp
spells/CDefaultSpellMechanics.cpp
spells/ViewSpellInt.cpp
spells/AdventureSpellMechanics.cpp
spells/BattleSpellMechanics.cpp
spells/CreatureSpellMechanics.cpp
spells/CDefaultSpellMechanics.cpp
spells/ViewSpellInt.cpp
BattleAction.cpp
BattleHex.cpp

View File

@ -11,10 +11,11 @@
*/
#include "ConstTransitivePtr.h"
#include "Version.h"
namespace GameConstants
{
const std::string VCMI_VERSION = "VCMI 0.98h " GIT_SHA1;
const std::string VCMI_VERSION = std::string("VCMI 0.98h ") + GIT_SHA1;
const int BFIELD_WIDTH = 17;
const int BFIELD_HEIGHT = 11;

View File

@ -1,15 +1,12 @@
project(vcmiserver)
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/lib)
include_directories(${Boost_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
set(server_SRCS
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
CGameHandler.cpp
CVCMIServer.cpp
CQuery.cpp

View File

@ -1,19 +1,16 @@
cmake_minimum_required(VERSION 2.6)
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
add_definitions(-DGIT_SHA1="${GIT_SHA1}")
enable_testing()
include_directories(${CMAKE_HOME_DIRECTORY} ${CMAKE_HOME_DIRECTORY}/include ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_HOME_DIRECTORY}/test)
include_directories(${Boost_INCLUDE_DIRS})
set(test_SRCS
StdInc.cpp
${CMAKE_BINARY_DIR}/Version.cpp
CVcmiTestConfig.cpp
CMapEditManagerTest.cpp
MapComparer.cpp
CMapFormatTest.cpp
MapComparer.cpp
CMapFormatTest.cpp
)
add_executable(vcmitest ${test_SRCS})