-
Notifications
You must be signed in to change notification settings - Fork 49
/
cmake.toml
161 lines (141 loc) · 4.54 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
150
151
152
153
154
155
156
157
158
159
160
161
# Reference: https://build-cpp.github.io/cmkr/cmake-toml
[project]
name = "safetyhook"
[options]
SAFETYHOOK_BUILD_DOCS = false
SAFETYHOOK_BUILD_TEST = false
SAFETYHOOK_BUILD_EXAMPLES = false
SAFETYHOOK_AMALGAMATE = false
SAFETYHOOK_FETCH_ZYDIS = false
SAFETYHOOK_USE_CXXMODULES = false
[conditions]
build-docs = "SAFETYHOOK_BUILD_DOCS"
build-test = "SAFETYHOOK_BUILD_TEST"
build-examples = "SAFETYHOOK_BUILD_EXAMPLES"
windows-only-example = "SAFETYHOOK_BUILD_EXAMPLES AND WIN32"
amalgamate = "SAFETYHOOK_AMALGAMATE"
build-amalgamate-test = "SAFETYHOOK_BUILD_TEST AND SAFETYHOOK_AMALGAMATE"
fetch-zydis = "SAFETYHOOK_FETCH_ZYDIS"
[fetch-content.ut]
condition = "build-test"
git = "https://github.com/boost-ext/ut.git"
tag = "v2.0.1"
shallow = true
[fetch-content.xbyak]
condition = "build-test"
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"]
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"]
cmake-after = """
if(SAFETYHOOK_USE_CXXMODULES)
target_compile_definitions(safetyhook INTERFACE SAFETYHOOK_USE_CXXMODULES)
endif()
"""
[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}
MAIN_DEPENDENCY ${AMALGAMATE_SCRIPT}
COMMENT "Amalgamating"
)
add_custom_target(Amalgamate ALL DEPENDS ${AMALGAMATED_FILE} ${AMALGAMATED_HEADER})
"""
[template.example]
condition = "build-examples"
type = "executable"
link-libraries = ["safetyhook::safetyhook"]
compile-features = ["cxx_std_23"]
[template.example-dll]
condition = "windows-only-example"
type = "shared"
link-libraries = ["safetyhook::safetyhook"]
compile-features = ["cxx_std_23"]
[target.example-minimal]
type = "example"
sources = ["example/minimal.cpp"]
[target.example-multiple]
type = "example"
sources = ["example/multiple.cpp"]
[target.example-midhook]
type = "example"
sources = ["example/midhook.cpp"]
[target.example-threadsafe]
type = "example"
sources = ["example/threadsafe.cpp"]
[target.example-dll]
type = "example-dll"
sources = ["example/dll.cpp"]
[target.example-vmthook]
type = "example"
sources = ["example/vmthook.cpp"]
[target.test]
condition = "build-test"
type = "executable"
sources = ["test/*.cpp"]
link-libraries = ["Boost::ut", "safetyhook::safetyhook", "xbyak::xbyak"]
compile-definitions = ["BOOST_UT_DISABLE_MODULE"]
compile-features = ["cxx_std_23"]
[target.test-amalgamated]
condition = "build-amalgamate-test"
type = "executable"
sources = ["test/*.cpp", "amalgamated-dist/safetyhook.cpp"]
include-directories = ["amalgamated-dist/"]
link-libraries = ["Zydis", "Boost::ut", "xbyak::xbyak"]
compile-definitions = ["BOOST_UT_DISABLE_MODULE"]
compile-features = ["cxx_std_23"]
cmake-after = """
add_dependencies(test-amalgamated Amalgamate)
"""