-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
68 lines (55 loc) · 2.09 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
project(unprecacher)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 17)
# src
set(THIRD_PARTY "${CMAKE_SOURCE_DIR}/third_party")
set(SRC_DIR "${CMAKE_SOURCE_DIR}/src")
file(GLOB_RECURSE SOURCE_FILES ${SRC_DIR}/*.h ${SRC_DIR}/*.cpp)
# api
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})
# tests
add_library(${PROJECT_NAME}_static STATIC ${SOURCE_FILES})
set_target_properties(${PROJECT_NAME}_static PROPERTIES COMPILE_FLAGS "-m32 -pipe -O0" LINK_FLAGS "-m32 -pipe -O0")
add_subdirectory(test)
# main
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES})
set(FLAGS "-m32 -O3 -pipe -fvisibility-inlines-hidden -fvisibility=hidden -flto -fPIC")
set_target_properties(
${PROJECT_NAME} PROPERTIES COMPILE_FLAGS
"${FLAGS} \
-fdata-sections \
-ffunction-sections \
-Wall \
-Wextra \
-Werror \
-Wstrict-aliasing \
-Weffc++ \
-Wunknown-pragmas"
)
set_target_properties(
${PROJECT_NAME} PROPERTIES LINK_FLAGS
"${FLAGS} \
-static-libgcc \
-static-libstdc++ \
-s \
-Wl,--version-script=${CMAKE_SOURCE_DIR}/version_script.lds \
-Wl,--gc-sections"
)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES SUFFIX "_i386.so")
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'Release' as none was specified.")
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release")
else()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-D_DEBUG)
endif()