mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Set windows EXE resource properties, resolves #329
This commit is contained in:
parent
7613f1b726
commit
a56bcc8903
118
cmake/GenerateProductVersion.cmake
Normal file
118
cmake/GenerateProductVersion.cmake
Normal file
@ -0,0 +1,118 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c) 2015, by [halex2005](mailto:akharlov@gmail.com)
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
# this software and associated documentation files (the "Software"), to deal in
|
||||
# the Software without restriction, including without limitation the rights to
|
||||
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
# the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
# subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
include (CMakeParseArguments)
|
||||
|
||||
set (GenerateProductVersionCurrentDir ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
# generate_product_version() function
|
||||
#
|
||||
# This function uses VersionInfo.in template file and VersionResource.rc file
|
||||
# to generate WIN32 resource with version information and general resource strings.
|
||||
#
|
||||
# Usage:
|
||||
# generate_product_version(
|
||||
# SomeOutputResourceVariable
|
||||
# NAME MyGreatProject
|
||||
# ICON ${PATH_TO_APP_ICON}
|
||||
# VERSION_MAJOR 2
|
||||
# VERSION_MINOR 3
|
||||
# VERSION_PATH ${BUILD_COUNTER}
|
||||
# VERSION_REVISION ${BUILD_REVISION}
|
||||
# )
|
||||
# where BUILD_COUNTER and BUILD_REVISION could be values from your CI server.
|
||||
#
|
||||
# You can use generated resource for your executable targets:
|
||||
# add_executable(target-name ${target-files} ${SomeOutputResourceVariable})
|
||||
#
|
||||
# You can specify resource strings in arguments:
|
||||
# NAME - name of executable (no defaults, ex: Microsoft Word)
|
||||
# BUNDLE - bundle (${NAME} is default, ex: Microsoft Office)
|
||||
# VERSION_MAJOR - 1 is default
|
||||
# VERSION_MINOR - 0 is default
|
||||
# VERSION_PATCH - 0 is default
|
||||
# COMPANY_NAME - your company name (no defaults)
|
||||
# COMPANY_COPYRIGHT - ${COMPANY_NAME} (C) Copyright ${CURRENT_YEAR} is default
|
||||
# COMMENTS - ${NAME} v${VERSION_MAJOR}.${VERSION_MINOR} is default
|
||||
# ORIGINAL_FILENAME - ${NAME} is default
|
||||
# INTERNAL_NAME - ${NAME} is default
|
||||
# FILE_DESCRIPTION - ${NAME} is default
|
||||
function(generate_product_version outfiles)
|
||||
set (options)
|
||||
set (oneValueArgs
|
||||
NAME
|
||||
BUNDLE
|
||||
VERSION_MAJOR
|
||||
VERSION_MINOR
|
||||
VERSION_PATCH
|
||||
COMPANY_NAME
|
||||
COMPANY_COPYRIGHT
|
||||
COMMENTS
|
||||
ORIGINAL_FILENAME
|
||||
INTERNAL_NAME
|
||||
FILE_DESCRIPTION)
|
||||
set (multiValueArgs)
|
||||
cmake_parse_arguments(PRODUCT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT PRODUCT_BUNDLE OR "${PRODUCT_BUNDLE}" STREQUAL "")
|
||||
set(PRODUCT_BUNDLE "${PRODUCT_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_VERSION_MAJOR OR "${PRODUCT_VERSION_MAJOR}" STREQUAL "")
|
||||
set(PRODUCT_VERSION_MAJOR 1)
|
||||
endif()
|
||||
if (NOT PRODUCT_VERSION_MINOR OR "${PRODUCT_VERSION_MINOR}" STREQUAL "")
|
||||
set(PRODUCT_VERSION_MINOR 0)
|
||||
endif()
|
||||
if (NOT PRODUCT_VERSION_PATCH OR "${PRODUCT_VERSION_PATCH}" STREQUAL "")
|
||||
set(PRODUCT_VERSION_PATCH 0)
|
||||
endif()
|
||||
|
||||
if (NOT PRODUCT_COMPANY_COPYRIGHT OR "${PRODUCT_COMPANY_COPYRIGHT}" STREQUAL "")
|
||||
string(TIMESTAMP PRODUCT_CURRENT_YEAR "%Y")
|
||||
set(PRODUCT_COMPANY_COPYRIGHT "Copyright (C) ${PRODUCT_CURRENT_YEAR} ${PRODUCT_COMPANY_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_COMMENTS OR "${PRODUCT_COMMENTS}" STREQUAL "")
|
||||
set(PRODUCT_COMMENTS "${PRODUCT_NAME} v${PRODUCT_VERSION_MAJOR}.${PRODUCT_VERSION_MINOR}")
|
||||
endif()
|
||||
if (NOT PRODUCT_ORIGINAL_FILENAME OR "${PRODUCT_ORIGINAL_FILENAME}" STREQUAL "")
|
||||
set(PRODUCT_ORIGINAL_FILENAME "${PRODUCT_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_INTERNAL_NAME OR "${PRODUCT_INTERNAL_NAME}" STREQUAL "")
|
||||
set(PRODUCT_INTERNAL_NAME "${PRODUCT_NAME}")
|
||||
endif()
|
||||
if (NOT PRODUCT_FILE_DESCRIPTION OR "${PRODUCT_FILE_DESCRIPTION}" STREQUAL "")
|
||||
set(PRODUCT_FILE_DESCRIPTION "${PRODUCT_NAME}")
|
||||
endif()
|
||||
|
||||
set (_VersionInfoFile ${CMAKE_CURRENT_BINARY_DIR}/VersionInfo.h)
|
||||
set (_VersionResourceFile ${CMAKE_CURRENT_BINARY_DIR}/VersionResource.rc)
|
||||
configure_file(
|
||||
${GenerateProductVersionCurrentDir}/VersionInfo.in
|
||||
${_VersionInfoFile}
|
||||
@ONLY)
|
||||
configure_file(
|
||||
${GenerateProductVersionCurrentDir}/VersionResource.rc
|
||||
${_VersionResourceFile}
|
||||
COPYONLY)
|
||||
list(APPEND ${outfiles} ${_VersionInfoFile} ${_VersionResourceFile})
|
||||
set (${outfiles} ${${outfiles}} PARENT_SCOPE)
|
||||
endfunction()
|
68
cmake/VersionInfo.in
Normal file
68
cmake/VersionInfo.in
Normal file
@ -0,0 +1,68 @@
|
||||
#pragma once
|
||||
|
||||
#ifndef PRODUCT_VERSION_MAJOR
|
||||
#define PRODUCT_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_VERSION_MINOR
|
||||
#define PRODUCT_VERSION_MINOR @PRODUCT_VERSION_MINOR@
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_VERSION_PATCH
|
||||
#define PRODUCT_VERSION_PATCH @PRODUCT_VERSION_PATCH@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_MAJOR
|
||||
#define FILE_VERSION_MAJOR @PRODUCT_VERSION_MAJOR@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_MINOR
|
||||
#define FILE_VERSION_MINOR @PRODUCT_VERSION_MINOR@
|
||||
#endif
|
||||
|
||||
#ifndef FILE_VERSION_PATCH
|
||||
#define FILE_VERSION_PATCH @PRODUCT_VERSION_PATCH@
|
||||
#endif
|
||||
|
||||
#ifndef __TO_STRING
|
||||
#define __TO_STRING_IMPL(x) #x
|
||||
#define __TO_STRING(x) __TO_STRING_IMPL(x)
|
||||
#endif
|
||||
|
||||
#define PRODUCT_VERSION_MAJOR_MINOR_STR __TO_STRING(PRODUCT_VERSION_MAJOR) "." __TO_STRING(PRODUCT_VERSION_MINOR)
|
||||
#define PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR PRODUCT_VERSION_MAJOR_MINOR_STR "." __TO_STRING(PRODUCT_VERSION_PATCH)
|
||||
#define PRODUCT_VERSION_RESOURCE PRODUCT_VERSION_MAJOR,PRODUCT_VERSION_MINOR,PRODUCT_VERSION_PATCH,0
|
||||
#define PRODUCT_VERSION_RESOURCE_STR PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR "\0"
|
||||
|
||||
#define FILE_VERSION_MAJOR_MINOR_STR __TO_STRING(FILE_VERSION_MAJOR) "." __TO_STRING(FILE_VERSION_MINOR)
|
||||
#define FILE_VERSION_MAJOR_MINOR_PATCH_STR FILE_VERSION_MAJOR_MINOR_STR "." __TO_STRING(FILE_VERSION_PATCH)
|
||||
#define FILE_VERSION_RESOURCE FILE_VERSION_MAJOR,FILE_VERSION_MINOR,FILE_VERSION_PATCH,0
|
||||
#define FILE_VERSION_RESOURCE_STR FILE_VERSION_MAJOR_MINOR_PATCH_STR "\0"
|
||||
|
||||
#ifndef PRODUCT_COMMENTS
|
||||
#define PRODUCT_COMMENTS "@PRODUCT_COMMENTS@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_COMPANY_NAME
|
||||
#define PRODUCT_COMPANY_NAME "@PRODUCT_COMPANY_NAME@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_COMPANY_COPYRIGHT
|
||||
#define PRODUCT_COMPANY_COPYRIGHT "@PRODUCT_COMPANY_COPYRIGHT@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_FILE_DESCRIPTION
|
||||
#define PRODUCT_FILE_DESCRIPTION "@PRODUCT_FILE_DESCRIPTION@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_INTERNAL_NAME
|
||||
#define PRODUCT_INTERNAL_NAME "@PRODUCT_NAME@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_ORIGINAL_FILENAME
|
||||
#define PRODUCT_ORIGINAL_FILENAME "@PRODUCT_ORIGINAL_FILENAME@\0"
|
||||
#endif
|
||||
|
||||
#ifndef PRODUCT_BUNDLE
|
||||
#define PRODUCT_BUNDLE "@PRODUCT_BUNDLE@\0"
|
||||
#endif
|
36
cmake/VersionResource.rc
Normal file
36
cmake/VersionResource.rc
Normal file
@ -0,0 +1,36 @@
|
||||
#include "VersionInfo.h"
|
||||
#include "winresrc.h"
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION FILE_VERSION_RESOURCE
|
||||
PRODUCTVERSION PRODUCT_VERSION_RESOURCE
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
#else
|
||||
FILEFLAGS 0x0L
|
||||
#endif
|
||||
FILEOS 0x4L
|
||||
FILETYPE 0x1L
|
||||
FILESUBTYPE 0x0L
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904b0"
|
||||
BEGIN
|
||||
VALUE "Comments", PRODUCT_COMMENTS
|
||||
VALUE "CompanyName", PRODUCT_COMPANY_NAME
|
||||
VALUE "FileDescription", PRODUCT_FILE_DESCRIPTION
|
||||
VALUE "FileVersion", FILE_VERSION_RESOURCE_STR
|
||||
VALUE "InternalName", PRODUCT_INTERNAL_NAME
|
||||
VALUE "LegalCopyright", PRODUCT_COMPANY_COPYRIGHT
|
||||
VALUE "OriginalFilename", PRODUCT_ORIGINAL_FILENAME
|
||||
VALUE "ProductName", PRODUCT_BUNDLE
|
||||
VALUE "ProductVersion", PRODUCT_VERSION_RESOURCE_STR
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x409, 1200
|
||||
END
|
||||
END
|
@ -204,7 +204,24 @@ if (UNIX AND NOT APPLE)
|
||||
target_link_libraries(keepassx_core Qt5::DBus)
|
||||
endif()
|
||||
|
||||
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE})
|
||||
if(MINGW)
|
||||
string(REPLACE "." ";" VERSION_LIST ${KEEPASSXC_VERSION})
|
||||
list(GET VERSION_LIST 0 KEEPASSXC_VERSION_MAJOR)
|
||||
list(GET VERSION_LIST 1 KEEPASSXC_VERSION_MINOR)
|
||||
list(GET VERSION_LIST 2 KEEPASSXC_VERSION_PATCH)
|
||||
|
||||
include(GenerateProductVersion)
|
||||
generate_product_version(
|
||||
WIN32_ProductVersionFiles
|
||||
NAME "KeePassXC"
|
||||
COMPANY_NAME "KeePassXC Team"
|
||||
VERSION_MAJOR ${KEEPASSXC_VERSION_MAJOR}
|
||||
VERSION_MINOR ${KEEPASSXC_VERSION_MINOR}
|
||||
VERSION_PATCH ${KEEPASSXC_VERSION_PATCH}
|
||||
)
|
||||
endif()
|
||||
|
||||
add_executable(${PROGNAME} WIN32 MACOSX_BUNDLE ${keepassx_SOURCES_MAINEXE} ${WIN32_ProductVersionFiles})
|
||||
target_link_libraries(${PROGNAME} keepassx_core)
|
||||
|
||||
set_target_properties(${PROGNAME} PROPERTIES ENABLE_EXPORTS ON)
|
||||
|
Loading…
Reference in New Issue
Block a user