forked from TheEVolk/xash3d-nodemod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
126 lines (106 loc) · 3.35 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
cmake_minimum_required(VERSION 3.21)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
include(VcpkgIntegration)
project(nodemod)
include(CompilerRuntime)
add_library(${PROJECT_NAME} SHARED
"src/lib/dllapi.cpp"
"src/lib/engine_api.cpp"
"src/lib/h_export.cpp"
"src/lib/meta_api.cpp"
"src/lib/public.cpp"
"src/node/nodeimpl.cpp"
"src/node/uvloop.cpp"
"src/node/resource.cpp"
"src/node/events.cpp"
"src/bindings/functions.cpp"
"src/bindings/bindings.cpp"
"src/bindings/players.cpp"
"src/common/logger.cpp"
"src/auto/dll_events.cpp"
"src/auto/dll_functions.cpp"
"src/auto/engine_events.cpp"
"src/auto/engine_functions.cpp"
"src/structures/entity.cpp"
)
find_path(HLSDK_DIRECTORY "cl_dll/GameStudioModelRenderer.h" PATH_SUFFIXES "hlsdk")
find_path(METAMOD_DIRECTORY "metamod/api_info.h" PATH_SUFFIXES "metamod")
target_include_directories(${PROJECT_NAME} PRIVATE
"${HLSDK_DIRECTORY}/common"
"${HLSDK_DIRECTORY}/dlls"
"${HLSDK_DIRECTORY}/engine"
"${HLSDK_DIRECTORY}/game_shared"
"${HLSDK_DIRECTORY}/pm_shared"
"${HLSDK_DIRECTORY}/public"
"${METAMOD_DIRECTORY}/metamod"
"src"
"deps/node/include"
"deps/v8"
"deps/uv"
)
set_target_properties(${PROJECT_NAME} PROPERTIES
OUTPUT_NAME "nodemod"
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
CXX_EXTENSIONS NO
)
# compiler options
if(WIN32)
target_compile_definitions(${PROJECT_NAME} PRIVATE
_CRT_SECURE_NO_WARNINGS=1 # disable CRT warnings
)
else()
target_compile_options(${PROJECT_NAME} PRIVATE -Wfatal-errors)
target_compile_options(${PROJECT_NAME} PRIVATE -fpermissive)
# these will break compatibility with other architectures
# but for now it's required for our purposes
target_compile_options(${PROJECT_NAME} PRIVATE -m32)
target_link_options(${PROJECT_NAME} PRIVATE -m32)
endif()
# link dependency libraries
# apply hacky workaround to bypass wrong CMAKE_SIZEOF_VOID_P value
set(BACKUP_CMAKE_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}")
set(CMAKE_SIZEOF_VOID_P "")
find_package(fmt CONFIG REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE fmt::fmt)
set(CMAKE_SIZEOF_VOID_P "${BACKUP_CMAKE_SIZEOF_VOID_P}")
# link platform-specific libraries
if(NOT WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE dl pthread)
endif()
# link Node.js library (in future this should be entirely handled by vcpkg)
if(WIN32)
target_link_libraries(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps/node/lib/Release/win32/libnode.lib")
else()
target_link_libraries(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps/node/lib/Release/linux/libnode.so.93")
endif()
# enable static runtime linking
set_compiler_runtime(${PROJECT_NAME} STATIC)
# set build output directory
set(DIR_COMMON_OUTPUT
${CMAKE_BINARY_DIR}/$<CONFIG>/bin
)
set_target_properties(${PROJECT_NAME} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${DIR_COMMON_OUTPUT}
LIBRARY_OUTPUT_DIRECTORY ${DIR_COMMON_OUTPUT}
RUNTIME_OUTPUT_DIRECTORY ${DIR_COMMON_OUTPUT}
)
install(TARGETS ${PROJECT_NAME}
DESTINATION "${CMAKE_INSTALL_PREFIX}"
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)