-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathsign_target.cmake
32 lines (32 loc) · 932 Bytes
/
sign_target.cmake
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
if(WIN32)
get_filename_component(
WINDOWS_10_KITS_ROOT
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]"
ABSOLUTE CACHE
)
set(WINDOWS_10_KIT_DIR "${WINDOWS_10_KITS_ROOT}/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "Current Windows 10 kit directory")
set(SIGNTOOL_KEY_ARGS "" CACHE STRING "Key arguments for signtool.exe - separate with ';'")
find_program(
SIGNTOOL_EXE
signtool
PATHS
"${WINDOWS_10_KIT_DIR}/x64"
"${WINDOWS_10_KIT_DIR}/x86"
DOC "Path to signtool.exe if SIGNTOOL_KEY_ARGS is set"
)
endif()
function(sign_target TARGET)
if(SIGNTOOL_KEY_ARGS AND WIN32)
add_custom_command(
TARGET ${TARGET} POST_BUILD
COMMAND
"${SIGNTOOL_EXE}"
ARGS
sign
${SIGNTOOL_KEY_ARGS}
/t http://timestamp.digicert.com
/fd SHA256
"$<TARGET_FILE:${TARGET}>"
)
endif()
endfunction()