forked from dkfans/keeperfx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
48 lines (38 loc) · 1.69 KB
/
Copy pathCMakeLists.txt
File metadata and controls
48 lines (38 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
cmake_minimum_required(VERSION 3.20)
# Do not allow building in root
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Do not build in the root. Create a bin directory and remove ${CMAKE_SOURCE_DIR}/CMakeCache.txt")
endif ()
project(keeperfx C CXX)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 20)
find_package(Git REQUIRED)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --always OUTPUT_VARIABLE COMMIT_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
file(STRINGS "${CMAKE_SOURCE_DIR}/version.mk" _kfx_version_lines)
foreach(_line IN LISTS _kfx_version_lines)
if(_line MATCHES "^(VER_MAJOR|VER_MINOR|VER_RELEASE|VER_BUILD)=([0-9]+)")
set(${CMAKE_MATCH_1} "${CMAKE_MATCH_2}")
endif()
endforeach()
foreach(_v VER_MAJOR VER_MINOR VER_RELEASE VER_BUILD)
if(NOT DEFINED ${_v})
message(FATAL_ERROR "version.mk is missing ${_v}")
endif()
endforeach()
# Override via -DBUILD_NUMBER=<n> -DPACKAGE_SUFFIX=<s>; used for the CPack name.
set(BUILD_NUMBER "${VER_BUILD}" CACHE STRING "Monotonic build number")
set(PACKAGE_SUFFIX "" CACHE STRING "Distribution suffix (e.g. Alpha, Release)")
set(VER_STRING "${VER_MAJOR}.${VER_MINOR}.${VER_RELEASE}.${BUILD_NUMBER} ${PACKAGE_SUFFIX}")
set(GIT_REVISION "${COMMIT_ID}")
# src/version.h includes "ver_defs.h" relative to src/ (matches GENSRC in Makefile).
configure_file(${CMAKE_SOURCE_DIR}/ver_defs.h.in ${CMAKE_SOURCE_DIR}/src/ver_defs.h)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/build/cmake/modules)
include(Helpers)
include(Platforms)
include(Dependencies)
include(BuildTargets)
# Windows icon resource is generated by png2ico in tools/.
if(WIN32)
add_subdirectory(tools)
endif()
include(Packaging)