From d14c8cf9ccaccb4c4d4d644f7d7886943e1b5230 Mon Sep 17 00:00:00 2001
From: Stephen Birarda <commit@birarda.com>
Date: Tue, 12 Jan 2016 15:55:14 -0800
Subject: [PATCH] add signing of DS and AC executable

---
 cmake/macros/InstallBesideConsole.cmake         | 4 ++++
 cmake/macros/OptionalWinExecutableSigning.cmake | 2 +-
 domain-server/CMakeLists.txt                    | 1 +
 interface/CMakeLists.txt                        | 1 -
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/cmake/macros/InstallBesideConsole.cmake b/cmake/macros/InstallBesideConsole.cmake
index 12bbc3bcda..f076c856f8 100644
--- a/cmake/macros/InstallBesideConsole.cmake
+++ b/cmake/macros/InstallBesideConsole.cmake
@@ -32,6 +32,10 @@ macro(install_beside_console)
         DESTINATION ${COMPONENT_DESTINATION}
         COMPONENT ${SERVER_COMPONENT}
       )
+
+      # on windows for PR and production builds, sign the executable
+      set(EXECUTABLE_COMPONENT ${SERVER_COMPONENT})
+      optional_win_executable_signing()
     endif ()
 
     if (TARGET_NAME STREQUAL domain-server)
diff --git a/cmake/macros/OptionalWinExecutableSigning.cmake b/cmake/macros/OptionalWinExecutableSigning.cmake
index 61eb26b3ed..00b4602834 100644
--- a/cmake/macros/OptionalWinExecutableSigning.cmake
+++ b/cmake/macros/OptionalWinExecutableSigning.cmake
@@ -22,7 +22,7 @@ macro(optional_win_executable_signing)
 
         # setup the post install command to sign the executable
         set(SIGN_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}"
+          /td SHA256 \${CMAKE_INSTALL_PREFIX}/$<TARGET_FILE_NAME:${TARGET_NAME}>"
         )
 
         install(CODE "execute_process(COMMAND ${SIGN_COMMAND})" COMPONENT ${EXECUTABLE_COMPONENT})
diff --git a/domain-server/CMakeLists.txt b/domain-server/CMakeLists.txt
index 342bfbffe4..347757ae38 100644
--- a/domain-server/CMakeLists.txt
+++ b/domain-server/CMakeLists.txt
@@ -37,4 +37,5 @@ if (UNIX)
 endif (UNIX)
 
 package_libraries_for_deployment()
+
 install_beside_console()
diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt
index aabfc1031c..51620fe800 100644
--- a/interface/CMakeLists.txt
+++ b/interface/CMakeLists.txt
@@ -239,7 +239,6 @@ else (APPLE)
       COMPONENT ${CLIENT_COMPONENT}
     )
 
-    set(EXECUTABLE_NAME "${INTERFACE_EXEC_PREFIX}.exe")
     set(EXECUTABLE_COMPONENT ${CLIENT_COMPONENT})
 
     optional_win_executable_signing()