make executable signing a post build step

This commit is contained in:
Stephen Birarda 2016-01-12 16:31:38 -08:00
parent e036531796
commit 44e1cdfe00
2 changed files with 8 additions and 15 deletions

View file

@ -20,23 +20,14 @@ macro(optional_win_executable_signing)
message(FATAL_ERROR "Code signing of executables was requested but signtool.exe could not be found.") message(FATAL_ERROR "Code signing of executables was requested but signtool.exe could not be found.")
endif () endif ()
if (NOT EXECUTABLE_NAME) if (NOT EXECUTABLE_PATH)
set(EXECUTABLE_NAME $<TARGET_FILE_NAME:${TARGET_NAME}>) set(EXECUTABLE_PATH $<TARGET_FILE_NAME:${TARGET_NAME}>)
endif () endif ()
# setup a post build command to sign the executable
add_custom_command( add_custom_command(
TARGET ${TARGET_NAME} POST_BUILD TARGET ${TARGET_NAME} POST_BUILD
COMMAND ${SIGNTOOL_EXEC} sign /f $ENV{HF_PFX_FILE} /p $ENV{HF_PFX_PASSPHRASE} /tr http://tsa.starfieldtech.com\ /td SHA256 $<TARGET_FILE_NAME:${TARGET_NAME}> COMMAND ${SIGNTOOL_EXEC} sign /f %HF_PFX_FILE% /p %HF_PFX_PASSPHRASE% /tr http://tsa.starfieldtech.com\ /td SHA256 ${EXECUTABLE_PATH}
)
# setup the post install command to sign the executable
install(CODE "\
message(STATUS \"Signing ${TARGET_NAME} with signtool.\")
execute_process(COMMAND ${SIGNTOOL_EXEC} sign /f $ENV{HF_PFX_FILE}\
/p $ENV{HF_PFX_PASSPHRASE} /tr http://tsa.starfieldtech.com\
/td SHA256 \${CMAKE_INSTALL_PREFIX}/${EXECUTABLE_NAME})
"
COMPONENT ${EXECUTABLE_COMPONENT}
) )
else () else ()
message(FATAL_ERROR "HF_PFX_PASSPHRASE must be set for executables to be signed.") message(FATAL_ERROR "HF_PFX_PASSPHRASE must be set for executables to be signed.")

View file

@ -30,14 +30,16 @@ if (APPLE)
COMPONENT ${SERVER_COMPONENT} COMPONENT ${SERVER_COMPONENT}
) )
elseif (WIN32) elseif (WIN32)
set(CONSOLE_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGED_CONSOLE_FOLDER}")
install( install(
DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${PACKAGED_CONSOLE_FOLDER}/" DIRECTORY "${CONSOLE_DESTINATION}/"
DESTINATION ${CONSOLE_INSTALL_DIR} DESTINATION ${CONSOLE_INSTALL_DIR}
COMPONENT ${SERVER_COMPONENT} COMPONENT ${SERVER_COMPONENT}
) )
# sign the copied server console executable after install # sign the copied server console executable after install
set(EXECUTABLE_NAME ${CONSOLE_EXEC_NAME}) set(EXECUTABLE_PATH "${CONSOLE_DESTINATION}/${CONSOLE_EXEC_NAME}")
optional_win_executable_signing() optional_win_executable_signing()
endif() endif()