-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
54 lines (40 loc) · 2.26 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
project(grip)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
enable_language(Rust)
include(CMakeCargo)
set(THIRD_PARTY "${CMAKE_SOURCE_DIR}/third_party")
set(SRC_DIR "${CMAKE_SOURCE_DIR}/cpp")
set(AMXXSDK "${THIRD_PARTY}/amxmodx/public")
set(METAMOD "${THIRD_PARTY}/metamod-hl1/metamod")
set(HLSDK "${THIRD_PARTY}/hlsdk")
set(API_INCLUDE_PATH "${HLSDK}/common ${HLSDK}/dlls ${HLSDK}/engine ${HLSDK}/pm_shared ${HLSDK}/game_shared ${HLSDK}/public ${METAMOD}")
string(REPLACE " " ";" API_INCLUDE_PATH_LIST ${API_INCLUDE_PATH})
include_directories(${API_INCLUDE_PATH_LIST})
include_directories(${AMXXSDK})
include_directories(${AMXXSDK}/sdk)
include_directories(${SRC_DIR}/helper)
add_subdirectory(rust)
file(GLOB_RECURSE SOURCE_FILES ${SRC_DIR}/*.h ${SRC_DIR}/*.cpp ${AMXXSDK}/sdk/*.cpp)
#${API_INCLUDE_PATH}/*.h ${API_INCLUDE_PATH}/*.cpp
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} )
set(FLAGS "-m32 -O3 -mtune=generic -fvisibility=hidden -flto -fPIC")
set(PORTABLE_LINK_FLAGS "${FLAGS} -static-libgcc -static-libstdc++ -Wl,--gc-sections -Wl,--version-script=${CMAKE_SOURCE_DIR}/version_script.lds")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${FLAGS} -fdata-sections -ffunction-sections -fpermissive")
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
if(WIN32)
target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}_rust Ws2_32 gcc Userenv Mswsock user32 Psapi Ncrypt Crypt32 Secur32 pthread)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${PORTABLE_LINK_FLAGS} -Wl,-L@CMakeFiles/../rust/i686-pc-windows-gnu/debug")
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX "_amxx_i386.dll")
else()
target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}-rust pthread) # TODO: Conditional dynamic linking of OpenSSL. (ssl crypto)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "${PORTABLE_LINK_FLAGS} -fuse-ld=lld")
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX "_amxx_i386.so")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wzero-as-null-pointer-constant -Wunknown-pragmas")
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_DEBUG)
endif()