forked from cursey/safetyhook
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcmake.toml
149 lines (130 loc) · 4.55 KB
/
cmake.toml
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
# Reference: https://build-cpp.github.io/cmkr/cmake-toml
[project]
name = "safetyhook"
[options]
SAFETYHOOK_BUILD_DOCS = false
SAFETYHOOK_BUILD_TESTS = false
SAFETYHOOK_AMALGAMATE = false
SAFETYHOOK_FETCH_ZYDIS = false
[conditions]
build-docs = "SAFETYHOOK_BUILD_DOCS"
build-tests = "SAFETYHOOK_BUILD_TESTS"
amalgamate = "SAFETYHOOK_AMALGAMATE"
build-amalgamate-tests = "SAFETYHOOK_BUILD_TESTS AND SAFETYHOOK_AMALGAMATE"
fetch-zydis = "SAFETYHOOK_FETCH_ZYDIS"
[fetch-content.Catch2]
condition = "build-tests"
git = "https://github.com/catchorg/Catch2.git"
tag = "v3.3.2"
shallow = true
[fetch-content.xbyak]
condition = "build-tests"
git = "https://github.com/herumi/xbyak.git"
tag = "v6.69"
shallow = true
[fetch-content.Zydis]
condition = "fetch-zydis"
git = "https://github.com/zyantific/zydis.git"
tag = "v4.0.0"
shallow = true
cmake-before = """
option(ZYDIS_BUILD_EXAMPLES "" OFF)
option(ZYDIS_BUILD_TOOLS "" OFF)
option(ZYDIS_BUILD_DOXYGEN "" OFF)
"""
[find-package.Doxygen]
condition = "build-docs"
required = true
[find-package.Python3]
condition = "amalgamate"
required = true
[target.safetyhook]
type = "static"
sources = ["src/*.cpp"]
include-directories = ["include/"]
compile-features = ["cxx_std_23"]
alias = "safetyhook::safetyhook"
link-libraries = ["Zydis", "ntdll"]
msvc.private-compile-options = ["/permissive-", "/W4", "/w14640"]
clang.private-compile-options = ["-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
gcc.private-compile-options = ["-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
[target.docs]
condition = "build-docs"
type = "custom"
cmake-before = """
file(GLOB_RECURSE HEADER_FILES include/*.hpp)
set(DOXYGEN_INDEX_FILE ${CMAKE_CURRENT_SOURCE_DIR}/docs/html/index.html)
set(DOXYFILE_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
set(DOXYFILE_OUT ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile)
configure_file(${DOXYFILE_IN} ${DOXYFILE_OUT})
add_custom_command(
OUTPUT ${DOXYGEN_INDEX_FILE}
DEPENDS ${HEADER_FILES}
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYFILE_OUT}
MAIN_DEPENDENCY ${DOXYFILE_OUT} ${DOXYFILE_IN}
COMMENT "Generating docs"
)
add_custom_target(Doxygen ALL DEPENDS ${DOXYGEN_INDEX_FILE})
"""
[target.amalgamation]
condition = "amalgamate"
type = "custom"
cmake-before = """
file(GLOB_RECURSE HEADER_FILES include/*.hpp)
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
set(AMALGAMATED_FILE ${CMAKE_CURRENT_SOURCE_DIR}/amalgamated-dist/safetyhook.cpp)
set(AMALGAMATED_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/amalgamated-dist/safetyhook.hpp)
set(AMALGAMATE_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/amalgamate.py)
add_custom_command(
OUTPUT ${AMALGAMATED_FILE} ${AMALGAMATED_HEADER}
DEPENDS ${HEADER_FILES} ${SOURCE_FILES} ${AMALGAMATE_SCRIPT}
COMMAND ${Python3_EXECUTABLE} ${AMALGAMATE_SCRIPT} ${AMALGAMATED_FILE} ${AMALGAMATED_HEADER}
MAIN_DEPENDENCY ${AMALGAMATE_SCRIPT}
COMMENT "Amalgamating"
)
add_custom_target(Amalgamate ALL DEPENDS ${AMALGAMATED_FILE} ${AMALGAMATED_HEADER})
"""
[template.test]
condition = "build-tests"
type = "executable"
link-libraries = ["safetyhook::safetyhook"]
compile-features = ["cxx_std_23"]
msvc.private-compile-options = ["/WX", "/permissive-", "/W4", "/w14640", "/EHsc"]
clang.private-compile-options = ["-Werror", "-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
gcc.private-compile-options = ["-Werror", "-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
[template.test-dll]
condition = "build-tests"
type = "shared"
link-libraries = ["safetyhook::safetyhook"]
compile-features = ["cxx_std_23"]
msvc.private-compile-options = ["/WX", "/permissive-", "/W4", "/w14640", "/EHsc"]
clang.private-compile-options = ["-Werror", "-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
gcc.private-compile-options = ["-Werror", "-Wall", "-Wextra", "-Wshadow", "-Wnon-virtual-dtor", "-pedantic"]
[target.test0]
type = "test"
sources = ["tests/test0.cpp"]
[target.test1]
type = "test"
sources = ["tests/test1.cpp"]
[target.test2]
type = "test"
sources = ["tests/test2.cpp"]
[target.test3]
type = "test"
sources = ["tests/test3.cpp"]
[target.test4]
type = "test-dll"
sources = ["tests/test4.cpp"]
[target.unittest]
type = "test"
sources = ["unittest/*.cpp"]
link-libraries = ["Catch2::Catch2WithMain", "safetyhook::safetyhook", "xbyak::xbyak"]
[target.unittest-amalgamated]
condition = "build-amalgamate-tests"
type = "test"
sources = ["unittest/*.cpp", "amalgamated-dist/safetyhook.cpp"]
include-directories = ["amalgamated-dist/"]
link-libraries = ["Zydis", "Catch2::Catch2WithMain", "xbyak::xbyak"]
cmake-after = """
add_dependencies(unittest-amalgamated Amalgamate)
"""