-
-
Notifications
You must be signed in to change notification settings - Fork 208
/
Copy pathCMakeLists.txt
122 lines (101 loc) · 3.64 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
cmake_minimum_required(VERSION 3.16)
project(SecureUxTheme)
set(CI_VERSION "(unknown)" CACHE STRING "Version string")
set(CI_VERSION_MAJOR "0" CACHE STRING "Version major number")
set(CI_VERSION_MINOR "0" CACHE STRING "Version minor number")
set(CI_VERSION_PATCH "0" CACHE STRING "Version patch number")
set(SIGN_SCRIPT "" CACHE STRING "Signing script, called like <script> <input> <output>")
add_compile_options(
"$<$<NOT:$<CONFIG:Debug>>:/Zi>"
/utf-8
/d1nodatetime
/W4
/wd4201 # C4201: nonstandard extension used: nameless struct/union
/wd4471 # C4471: a forward declaration of an unscoped enumeration must have an underlying type
/wd4324 # C4324: structure was padded due to alignment specifier
/WX
)
add_link_options(
"$<$<NOT:$<CONFIG:Debug>>:/DEBUG>"
"$<$<NOT:$<CONFIG:Debug>>:/OPT:REF>"
"$<$<NOT:$<CONFIG:Debug>>:/OPT:ICF=10>"
/Brepro
/PDBALTPATH:%_PDB%
/FILEALIGN:0x1000
/NOVCFEATURE
/NOCOFFGRPINFO
)
add_compile_definitions(
UNICODE
_UNICODE
"CI_VERSION=\"${CI_VERSION}\""
"CI_VERSION_MAJOR=${CI_VERSION_MAJOR}"
"CI_VERSION_MINOR=${CI_VERSION_MINOR}"
"CI_VERSION_PATCH=${CI_VERSION_PATCH}"
)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_CXX_STANDARD 20)
add_subdirectory(phnt)
add_library(SecureUxTheme SHARED SecureUxTheme/avrf.cpp)
target_link_libraries(SecureUxTheme PRIVATE phnt::phnt ntdll.lib ntdllp.lib)
target_compile_options(SecureUxTheme PRIVATE
/GS-
)
target_link_options(SecureUxTheme PRIVATE
/NODEFAULTLIB
/ENTRY:DllMain
)
set(SECUREUXTHEME_SIGNED_PATH "${CMAKE_CURRENT_BINARY_DIR}/SecureUxTheme.signed.dll")
set(SECUREUXTHEME_HEADER_DIR "${CMAKE_CURRENT_BINARY_DIR}/SecureUxTheme_header")
set(SECUREUXTHEME_HEADER_PATH "${SECUREUXTHEME_HEADER_DIR}/SecureUxTheme.dll.h")
file(MAKE_DIRECTORY "${SECUREUXTHEME_HEADER_DIR}")
add_library(SecureUxTheme_header INTERFACE)
target_sources(SecureUxTheme_header PUBLIC
FILE_SET HEADERS
BASE_DIRS "${CMAKE_CURRENT_BINARY_DIR}/SecureUxTheme_header"
FILES "${SECUREUXTHEME_HEADER_PATH}"
)
target_include_directories(SecureUxTheme_header INTERFACE "${SECUREUXTHEME_HEADER_DIR}")
if ("${SIGN_SCRIPT}" STREQUAL "")
configure_file("$<TARGET_FILE:SecureUxTheme>" "${SECUREUXTHEME_SIGNED_PATH}" COPYONLY)
else ()
add_custom_command(
OUTPUT "${SECUREUXTHEME_SIGNED_PATH}"
COMMAND "${SIGN_SCRIPT}"
"$<TARGET_FILE:SecureUxTheme>"
"${SECUREUXTHEME_SIGNED_PATH}"
DEPENDS "$<TARGET_FILE:SecureUxTheme>"
VERBATIM
)
endif ()
add_custom_command(
OUTPUT "${SECUREUXTHEME_HEADER_PATH}"
COMMAND powershell -NoProfile -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_SOURCE_DIR}/bin2h.ps1"
"${SECUREUXTHEME_SIGNED_PATH}"
"${SECUREUXTHEME_HEADER_PATH}"
DEPENDS "${SECUREUXTHEME_SIGNED_PATH}"
VERBATIM
)
add_library(ThemeLib STATIC
ThemeLib/install.cpp
ThemeLib/signature.cpp
ThemeLib/theme.cpp
)
target_link_libraries(ThemeLib PRIVATE SecureUxTheme_header phnt::phnt)
target_include_directories(ThemeLib PUBLIC ThemeLib/public)
add_library(ThemeDll SHARED
ThemeDll/dllmain.cpp
ThemeDll/exports.def
)
target_link_libraries(ThemeDll PRIVATE ThemeLib)
add_executable(ThemeTool WIN32
ThemeTool/main.cpp
ThemeTool/MainDialog.cpp
ThemeTool/utl.cpp
ThemeTool/ThemeTool.rc
)
target_precompile_headers(ThemeTool PRIVATE ThemeTool/pch.h)
target_link_libraries(ThemeTool PRIVATE
ThemeLib
phnt::phnt
)