-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
105 lines (87 loc) · 3.44 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
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
cmake_minimum_required(VERSION 2.8.8)
project(debugger)
option(DEBUGGER_USE_STATIC_RUNTIME "Use static C++ runtime" ON)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
include(GetGitRevisionDescription)
# Enable project folders in Visual Studio 2010+ (and possibly other IDEs).
if(NOT (MSVC_IDE AND MSVC_VERSION LESS 1600))
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()
# Suppress annoying GCC warning about 'packed' attribute being ignored.
if(CMAKE_COMPILER_IS_GNUCC)
if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-attributes")
endif()
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
endif()
endif()
# Do the same for Clang.
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-ignored-attributes")
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-attributes")
endif()
# This fixes compile errors on 64-bit systems.
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 4)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32")
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
endif()
endif()
# Link against the static version of libstdc++.
if(DEBUGGER_USE_STATIC_RUNTIME)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc")
endif()
endif()
# Disalow the use of SSE2 instruction set on Windows. Some people still have
# old CPUs on their home PCs that do not support SSE2 and hosts typically use
# modern CPUs and mostly run Linux.
if(WIN32)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /arch:SSE")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=pentium3m")
endif()
endif()
SET(SUBHOOK_STATIC ON CACHE BOOL "Subhook static build")
SET(SUBHOOK_FORCE_32BIT ON CACHE BOOL "Subhook force 32 bit")
SET(SUBHOOK_TESTS OFF CACHE BOOL "Subhook build tests")
add_subdirectory(deps/subhook)
add_subdirectory(deps/brynet)
git_describe(description --match "v[0-9]*.[0-9]**")
if(description)
string(REGEX REPLACE "\\-g[0-9a-f]+$" "" description ${description})
string(REGEX REPLACE "^v(.*)" "\\1" version ${description})
else()
message(STATUS "Failed to get version from Git, will read VERSION.txt")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION.txt" version)
string(STRIP ${version} version)
endif()
# Comma-separated version for RC.
string(REGEX REPLACE "[.]" "," version_rc ${version})
string(REGEX REPLACE "[-].*" "" version_rc ${version_rc})
# Append one or two ",0" to the end to make windres happy.
string(REGEX REPLACE "^([0-9]+,[0-9]+)$" "\\1,0,0" version_rc ${version_rc})
string(REGEX REPLACE "^([0-9]+,[0-9]+,[0-9]+)$" "\\1,0" version_rc ${version_rc})
set(PROJECT_VERSION ${version})
set(PROJECT_VERSION_RC ${version_rc})
add_subdirectory(src)
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
if(WIN32)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-win32")
set(CPACK_GENERATOR ZIP)
elseif(UNIX)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-linux")
set(CPACK_GENERATOR TGZ)
endif()
include(CPack)
message(STATUS "You're going to build ${PROJECT_NAME} v${PROJECT_VERSION}")