
############################################################################
# Project version information
############################################################################

SET(C4PROJECT           "OpenClonk Project")
SET(C4PROJECT_DOMAIN    "openclonk")
SET(C4PROJECT_TLD       "org")
SET(C4PROJECT_URL       "http://www.{C4PROJECT_DOMAIN}.{C4PROJECT_TLD}")

IF(CMAKE_HOST_UNIX)
	EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE DATE)
ELSEIF(CMAKE_HOST_WIN32)
	EXECUTE_PROCESS(COMMAND "cscript.exe" "//nologo" "${CMAKE_CURRENT_SOURCE_DIR}/tools/get_current_year.vbs" OUTPUT_VARIABLE DATE)
ENDIF()
STRING(REGEX REPLACE "(.+)\n" "\\1" YEARFIXED "${DATE}")
SET(C4COPYRIGHT_YEAR ${YEARFIXED})

SET(C4ENGINENAME        "OpenClonk")
SET(C4ENGINENICK        "openclonk")
SET(C4ENGINECAPTION     ${C4ENGINENAME})
SET(C4ENGINEID          "${C4PROJECT_TLD}.${C4PROJECT_DOMAIN}.${C4ENGINENICK}")

SET(C4XVER1             5)
SET(C4XVER2             1)
SET(C4XVER3             90)
SET(C4XVER4             0)

# C4VERSIONBUILDNAME should be witty and somewhat frequently changing
# for alpha and beta releases, and meaningful and stable for stable releases.
SET(C4VERSIONBUILDNAME  "Schokokeks")

SET(C4VERSIONEXTRA      "Alpha")

############################################################################
# Get revision from Mercurial
############################################################################

# Note: This will not work for source distributions!
execute_process(WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
	COMMAND "hg" "id" "--id"
	OUTPUT_VARIABLE C4REVISION
	OUTPUT_STRIP_TRAILING_WHITESPACE)

############################################################################
# Build version strings
############################################################################

set(C4ENGINEINFO "${C4ENGINENAME}")
set(C4SHORTVERSION "${C4XVER1}.${C4XVER2}.${C4XVER3}.${C4XVER4}")
set(C4VERSION "${C4SHORTVERSION}")

if(C4XVERBUILD LESS 10)
	set(C4VERSION "${C4VERSION} [00${C4XVERBUILD}]")
elseif(C4XVERBUILD LESS 100)
	set(C4VERSION "${C4VERSION} [0${C4XVERBUILD}]")
else()
	set(C4VERSION "${C4VERSION} [${C4XVERBUILD}]")
endif()

if(NOT ${C4VERSIONEXTRA} STREQUAL "")
	set(C4ENGINEINFO "${C4ENGINENAME} ${C4VERSIONEXTRA}")
	set(C4VERSION "${C4VERSION} ${C4VERSIONEXTRA}")
endif()

if(WIN32)
	set(C4VERSION "${C4VERSION} win")
elseif(APPLE)
	set(C4VERSION "${C4VERSION} mac")
elseif(UNIX)
	set(C4VERSION "${C4VERSION} unix")
else()
	set(C4VERSION "${C4VERSION} strange")
endif()

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/src/C4Version.h.in ${CMAKE_CURRENT_BINARY_DIR}/C4Version.h ESCAPE_QUOTES)

