Commit 8c9c2431 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

When using SIGNCODE parameter, check that signing of test executable reaööy works.

If not,  write warning and disable signing

Also, set SIGNCODE in mysql_release build configuration.
parent c2e1fdf5
......@@ -90,6 +90,11 @@ IF(NOT COMPILATION_COMMENT)
SET(COMPILATION_COMMENT "MySQL Community Server (GPL)")
ENDIF()
IF(WIN32)
# Sign executables with authenticode certificate
SET(SIGNCODE 1 CACHE BOOL "")
ENDIF()
IF(UNIX)
SET(WITH_EXTRA_CHARSETS all CACHE STRING "")
IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
......
......@@ -85,6 +85,24 @@ IF(WIN32)
MESSAGE(FATAL_ERROR
"signtool is not found. Signing executables not possible")
ENDIF()
IF(NOT DEFINED SIGNCODE_ENABLED)
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/testsign.c "int main(){return 0;}")
MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/testsign)
TRY_COMPILE(RESULT ${CMAKE_CURRENT_BINARY_DIR}/testsign ${CMAKE_CURRENT_BINARY_DIR}/testsign.c
COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe
)
EXECUTE_PROCESS(COMMAND
${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe
RESULT_VARIABLE ERR ERROR_QUIET OUTPUT_QUIET
)
IF(ERR EQUAL 0)
SET(SIGNCODE_ENABLED 1 CACHE INTERNAL "Can sign executables")
ELSE()
MESSAGE(STATUS "Disable authenticode signing for executables")
SET(SIGNCODE_ENABLED 0 CACHE INTERNAL "Invalid or missing certificate")
ENDIF()
ENDIF()
MARK_AS_ADVANCED(SIGNTOOL_EXECUTABLE SIGNTOOL_PARAMETERS)
ENDIF()
ENDIF()
......@@ -100,7 +118,7 @@ MACRO(SIGN_TARGET target)
INSTALL(CODE
"EXECUTE_PROCESS(COMMAND
${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${target_location}
ERROR_VARIABLE ERR)
RESULT_VARIABLE ERR)
IF(NOT \${ERR} EQUAL 0)
MESSAGE(FATAL_ERROR \"Error signing ${target_location}\")
ENDIF()
......@@ -131,7 +149,7 @@ FUNCTION(MYSQL_INSTALL_TARGETS)
# If signing is required, sign executables before installing
FOREACH(target ${TARGETS})
IF(SIGNCODE)
IF(SIGNCODE AND SIGNCODE_ENABLED)
SIGN_TARGET(${target})
ENDIF()
ADD_VERSION_INFO(${target})
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment