-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
152 lines (136 loc) · 4.42 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
cmake_minimum_required(VERSION 3.17)
project(NKHook5 VERSION 1.0 LANGUAGES CXX)
include(FetchContent)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
# Only Visual Studio platforms are supported
if (NOT CMAKE_GENERATOR_PLATFORM STREQUAL Win32)
message(FATAL_ERROR "NKHook5 can only be built on Win32 using the Visual Studio 17 2022 or newer generator.")
endif ()
message("BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "Release"))
message(FATAL_ERROR "NKHook5 can only be built in Debug or Release mode.")
endif()
#Get the git diff ID thing and make a compile def for it
EXECUTE_PROCESS(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE "NKHOOK_BUILD_VERSION"
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
add_compile_definitions(NKHOOK_BUILD_TAG=0.10.1.1)
add_compile_definitions(NKHOOK_BUILD_VERSION=${NKHOOK_BUILD_VERSION})
add_compile_definitions(_ITERATOR_DEBUG_LEVEL=0)
add_compile_options(/openmp)
if(MSVC)
add_compile_options(
$<$<CONFIG:>:/MT> #---------|
$<$<CONFIG:Debug>:/MTd> #---|-- Statically link the runtime libraries
$<$<CONFIG:Release>:/MT> #--|
$<$<CONFIG:RelWithDebInfo>:/MT> #--|
)
endif()
#Fetch & Install PolyHook2
FetchContent_Declare(
plh
GIT_REPOSITORY https://github.com/stevemk14ebr/PolyHook_2_0.git
GIT_TAG e8d33f54f9d11943f86fc326dae31dcc8ea7c389
)
FetchContent_GetProperties(plh)
if(NOT plh_POPULATED)
FetchContent_Populate(plh)
set(POLYHOOK_BUILD_DLL ON)
add_subdirectory(${plh_SOURCE_DIR} ${plh_BINARY_DIR})
endif()
FetchContent_Declare(
json
GIT_REPOSITORY https://github.com/nlohmann/json.git
GIT_TAG master
)
FetchContent_GetProperties(json)
if(NOT json_POPULATED)
FetchContent_Populate(json)
add_subdirectory(${json_SOURCE_DIR} ${json_BINARY_DIR})
include_directories(${json_SOURCE_DIR}/include)
endif()
FetchContent_Declare(
menum
GIT_REPOSITORY https://github.com/Neargye/magic_enum.git
GIT_TAG master
)
FetchContent_GetProperties(menum)
if(NOT menum_POPULATED)
FetchContent_Populate(menum)
add_subdirectory(${menum_SOURCE_DIR} ${menum_BINARY_DIR})
endif()
FetchContent_Declare(
cli11
GIT_REPOSITORY https://github.com/CLIUtils/CLI11
GIT_TAG v2.2.0
)
FetchContent_MakeAvailable(cli11)
FetchContent_Declare(
stb
GIT_REPOSITORY https://github.com/nothings/stb.git
GIT_TAG master
)
FetchContent_GetProperties(stb)
if(NOT stb_POPULATED)
FetchContent_Populate(stb)
add_library(stb INTERFACE)
target_include_directories(stb INTERFACE ${stb_SOURCE_DIR})
endif()
FetchContent_Declare(
binpack
GIT_REPOSITORY https://github.com/chris-stones/BinPack2D.git
GIT_TAG master
)
FetchContent_GetProperties(binpack)
if(NOT binpack_POPULATED)
FetchContent_Populate(binpack)
add_library(binpack INTERFACE)
target_include_directories(binpack INTERFACE ${binpack_SOURCE_DIR})
endif()
FetchContent_Declare(
libhat
GIT_REPOSITORY https://github.com/DisabledMallis/libhat.git
GIT_TAG master
)
FetchContent_GetProperties(libhat)
if(NOT libhat_POPULATED)
FetchContent_Populate(libhat)
message("${libhat_SOURCE_DIR}")
message("${libhat_BINARY_DIR}")
add_subdirectory(${libhat_SOURCE_DIR} ${libhat_BINARY_DIR})
endif()
set(BOOST_INCLUDE_LIBRARIES config container intrusive smart_ptr spirit variant)
set(BOOST_ENABLE_CMAKE ON)
FetchContent_Declare(
Boost
GIT_REPOSITORY https://github.com/boostorg/boost.git
GIT_TAG boost-1.80.0
OVERRIDE_FIND_PACKAGE
)
FetchContent_MakeAvailable(Boost)
set(Boost_INCLUDE_DIR ${Boost_SOURCE_DIR})
set(Boost_ROOT ${Boost_SOURCE_DIR})
FetchContent_Declare(
jsonspirit
GIT_REPOSITORY https://github.com/png85/json_spirit.git
GIT_TAG master
)
FetchContent_GetProperties(jsonspirit)
if(NOT jsonspirit_POPULATED)
FetchContent_Populate(jsonspirit)
set(BUILD_STATIC_LIBRARIES ON)
set(BUILD_STATIC_LIBS ON)
set(JSON_SPIRIT_DEMOS OFF)
set(JSON_SPIRIT_TESTS OFF)
add_subdirectory(${jsonspirit_SOURCE_DIR} ${jsonspirit_BINARY_DIR})
target_include_directories(json_spirit PUBLIC ${jsonspirit_SOURCE_DIR})
target_link_libraries(json_spirit PRIVATE Boost::config Boost::smart_ptr Boost::spirit Boost::variant)
endif()
add_subdirectory(Common)
add_subdirectory(DevKit)
add_subdirectory(NKHook5)
add_subdirectory(Loader)