-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
106 lines (87 loc) · 4.02 KB
/
CMakeLists.txt
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
96
97
98
99
100
101
102
103
104
105
106
cmake_minimum_required(VERSION 3.20)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
project(Hell2Modding CXX C ASM_MASM)
set(SRC_DIR "${PROJECT_SOURCE_DIR}/src")
# Fetch modules
message("\nFetching modules")
include(cmake_scripts/eastl.cmake)
include(cmake_scripts/git.cmake)
include(cmake_scripts/lpeg.cmake)
include(cmake_scripts/luasocket.cmake)
include(cmake_scripts/raw_pdb.cmake)
include(cmake_scripts/rom.cmake)
include(cmake_scripts/tolk.cmake)
message(STATUS "Hell2Modding")
file(GLOB_RECURSE SRC_MAIN
"${SRC_DIR}/**.hpp"
"${SRC_DIR}/**.h"
"${SRC_DIR}/**.cpp"
"${SRC_DIR}/**.cc"
"${SRC_DIR}/**.cxx"
"${SRC_DIR}/**.asm"
"${SRC_DIR}/**.def"
"${SRC_DIR}/**.rc"
)
add_compile_options(/bigobj)
add_compile_options("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
if (FINAL)
add_compile_definitions(FINAL)
endif()
add_library(Hell2Modding MODULE "${SRC_MAIN}")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set_property(TARGET Hell2Modding PROPERTY CXX_STANDARD 23)
source_group(TREE ${SRC_DIR} PREFIX "src" FILES ${SRC_MAIN})
target_include_directories(Hell2Modding PRIVATE
"${SRC_DIR}"
"${eastl_SOURCE_DIR}/include"
"${tolk_SOURCE_DIR}/include"
"${lpeg_SOURCE_DIR}"
"${luasocket_SOURCE_DIR}/src"
"${raw_pdb_SOURCE_DIR}/src"
)
target_precompile_headers(Hell2Modding PRIVATE "${SRC_DIR}/common.hpp")
target_link_libraries(Hell2Modding PRIVATE ReturnOfModdingBase Tolk lpeg_static luasocket_static wsock32 ws2_32 EASTL raw_pdb)
# Warnings as errors
set_property(TARGET Hell2Modding PROPERTY COMPILE_WARNING_AS_ERROR ON)
add_compile_definitions(Hell2Modding
"_CRT_SECURE_NO_WARNINGS"
"NOMINMAX"
"WIN32_LEAN_AND_MEAN"
)
if (MSVC)
if (FINAL)
# Aggresive inlining (Release)
string(REPLACE "Ob2" "Ob3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
# Aggresive inlining (RelWithDebInfo)
string(REPLACE "Ob1" "Ob3" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
# Enable intrinsics
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Oi")
# Favor fast code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Ot")
# -ffast-math (fused multiply-add if the arch allows)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /fp:fast")
# Whole program optimization
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GL")
# Function-level linking
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gy")
# Disable Buffer Security Check
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /GS-")
# Package global data in COMDAT sections for optimization.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Gw")
# For all objects:
# - strip unused functions
# - fold identical functions
# - link-time code generation
string(REPLACE "INCREMENTAL" "INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
string(REPLACE "INCREMENTAL" "INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO}")
string(REPLACE "INCREMENTAL" "INCREMENTAL:NO" CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO}")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /OPT:ICF,REF /LTCG")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /OPT:ICF,REF /LTCG")
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /OPT:ICF,REF /LTCG")
set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO} /PDBALTPATH:d3d12.pdb")
set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO} /PDBALTPATH:d3d12.pdb")
set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO} /PDBALTPATH:d3d12.pdb")
endif()
endif()
set_target_properties(Hell2Modding PROPERTIES OUTPUT_NAME "d3d12_")