FILE(GLOB_RECURSE files "@CMAKE_BINARY_DIR@/*.signme")
MESSAGE(STATUS "signing files")
FOREACH(f ${files})
  STRING(REPLACE ".signme" "" exe_location "${f}")

  string (REPLACE ";" " " params "@SIGNTOOL_PARAMETERS@")
  #MESSAGE("@SIGNTOOL_EXECUTABLE@" sign ${params} "${exe_location}")

  EXECUTE_PROCESS(COMMAND
    "@SIGNTOOL_EXECUTABLE@" sign @SIGNTOOL_PARAMETERS@ "${exe_location}"
     RESULT_VARIABLE ERR)
  IF(NOT ${ERR} EQUAL 0)
    MESSAGE( "Error ${ERR} signing ${exe_location}")
  ELSE()
    FILE(REMOVE ${f})
  ENDIF()

ENDFOREACH()
