-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
95 lines (78 loc) · 3.67 KB
/
Copy pathCMakeLists.txt
File metadata and controls
95 lines (78 loc) · 3.67 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
cmake_minimum_required(VERSION 3.23)
project(OpenTS VERSION 0.2.0 LANGUAGES C CXX)
# A SemVer prerelease label, which project() cannot carry because it takes numbers only. Set it
# to "beta1" and the version reads 0.1.0-beta1; leave it empty outside a prerelease series. The
# manual's release registry is checked against both this and the project version.
set(OPENTS_VERSION_PRERELEASE "")
# Marks a build published under the version it declares, so that it is named by that version
# alone. Every other build names the commit it came from as well.
option(OPENTS_OFFICIAL_BUILD "Build as an official release of the declared version" OFF)
option(OPENTS_EXPERIMENTAL_CLANG_CL "Build with clang-cl using the MSVC ABI" OFF)
# Lets a target's FOLDER place it in a Visual Studio solution folder. The bgfx submodule sets
# this as well, so declare it here rather than inherit it from a vendored build.
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
if(NOT OPENTS_EXPERIMENTAL_CLANG_CL)
message(FATAL_ERROR
"The unsupported clang-cl experiment must be configured with "
"-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/clang-cl-msvc.cmake.")
endif()
elseif(MSVC)
if(MSVC_VERSION LESS 1930)
message(FATAL_ERROR "OpenTS requires MSVC 19.30 or newer.")
endif()
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(FATAL_ERROR
"OpenTS targets Win32 and x64. Reconfigure with -A Win32 or -A x64.")
endif()
else()
message(FATAL_ERROR
"OpenTS requires the Visual Studio 2022 MSVC toolchain. "
"For the unsupported clang-cl experiment, configure with "
"-DCMAKE_TOOLCHAIN_FILE=cmake/toolchains/clang-cl-msvc.cmake.")
endif()
string(TOLOWER "${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" OPENTS_ARCH)
if(NOT OPENTS_ARCH)
set(OPENTS_ARCH "unknown")
endif()
enable_language(RC)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OPENTS_GAME_DIR "${CMAKE_SOURCE_DIR}/Run" CACHE PATH "Tiberian Sun game data directory")
#
# ---------------------------------------------------------
# Build identity stamp
# ---------------------------------------------------------
#
# The version resources, the version displays, and the debug log's opening banner all report
# the version and commit that produced the binary. Stamping runs once here so the headers exist
# before the first compile, and again per build through OpenTSBuildStamp so that committing does
# not require a reconfigure to be reflected.
set(OPENTS_GENERATED_DIR "${CMAKE_BINARY_DIR}/generated")
set(OPENTS_VERSION_HEADER "${OPENTS_GENERATED_DIR}/opents_version.h")
set(OPENTS_STAMP_HEADER "${OPENTS_GENERATED_DIR}/opents_build.h")
file(MAKE_DIRECTORY "${OPENTS_GENERATED_DIR}")
set(OPENTS_STAMP_ARGS
"-DOPENTS_VERSION_MAJOR=${PROJECT_VERSION_MAJOR}"
"-DOPENTS_VERSION_MINOR=${PROJECT_VERSION_MINOR}"
"-DOPENTS_VERSION_PATCH=${PROJECT_VERSION_PATCH}"
"-DOPENTS_VERSION_PRERELEASE=${OPENTS_VERSION_PRERELEASE}"
"-DOPENTS_OFFICIAL_BUILD=${OPENTS_OFFICIAL_BUILD}"
"-DOPENTS_SOURCE_DIR=${CMAKE_SOURCE_DIR}"
"-DOPENTS_VERSION_HEADER=${OPENTS_VERSION_HEADER}"
"-DOPENTS_STAMP_HEADER=${OPENTS_STAMP_HEADER}"
"-DOPENTS_ARCH=${OPENTS_ARCH}"
-P "${CMAKE_SOURCE_DIR}/cmake/GitStamp.cmake"
)
execute_process(COMMAND ${CMAKE_COMMAND} ${OPENTS_STAMP_ARGS})
add_custom_target(OpenTSBuildStamp ALL
COMMAND ${CMAKE_COMMAND} ${OPENTS_STAMP_ARGS}
COMMENT "Stamping the build identity"
VERBATIM
)
add_subdirectory(thirdparty)
add_subdirectory(code)
add_subdirectory(code/language)
enable_testing()
add_subdirectory(tests)