Skip to content

Instantly share code, notes, and snippets.

@nicolas17
Last active December 31, 2015 21:39
Show Gist options
  • Save nicolas17/8047861 to your computer and use it in GitHub Desktop.
Save nicolas17/8047861 to your computer and use it in GitHub Desktop.
Add Windows version information to KF5 DLLs
function(WIN32_GEN_VERSION_INFO srclist)
if(NOT WIN32)
return()
endif()
set(options )
set(oneValueArgs VERSION VERSIONSTR FILE_DESC PRODUCT_NAME TARGET COMPANY_NAME)
set(multiValueArgs )
cmake_parse_arguments(WVI "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
# Decompose the version number into four components. Only the first two components are required,
# the other two will be replaced with 0 if missing. Also, more text can follow the four components,
# such as 1.0-beta1 which will be interpreted as 1.0.
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" _major "${WVI_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" _minor "${WVI_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch "${WVI_VERSION}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _revision "${WVI_VERSION}")
if(${_patch} STREQUAL ${WVI_VERSION})
set(_patch 0)
endif()
if(${_revision} STREQUAL ${WVI_VERSION})
set(_revision 0)
endif()
if(NOT WVI_VERSIONSTR)
set(WVI_VERSIONSTR "${WVI_VERSION}")
endif()
set(VERSION_COMMAS "${_major},${_minor},${_patch},${_revision}")
set(VERSIONSTR "${WVI_VERSIONSTR}")
set(FILEDESC "${WVI_FILE_DESC}")
set(PRODUCTNAME "${WVI_PRODUCT_NAME}")
set(COMPANYNAME "${WVI_COMPANY_NAME}")
set(output "${CMAKE_CURRENT_BINARY_DIR}/${WVI_TARGET}_version.rc")
configure_file(version.rc.in ${output})
set(${srclist} ${${srclist}} ${output} PARENT_SCOPE)
endfunction()
set(ThreadWeaver_LIB_SRCS
queuesignals.cpp
queuestream.cpp
queueapi.cpp
exception.cpp
queue.cpp
weaver.cpp
debuggingaids.cpp
thread.cpp
job.cpp
iddecorator.cpp
qobjectdecorator.cpp
executor.cpp
executewrapper.cpp
state.cpp
weaverimplstate.cpp
inconstructionstate.cpp
workinghardstate.cpp
suspendingstate.cpp
suspendedstate.cpp
shuttingdownstate.cpp
destructedstate.cpp
collection.cpp
sequence.cpp
dependencypolicy.cpp
dependency.cpp
resourcerestrictionpolicy.cpp
)
WIN32_GEN_VERSION_INFO(ThreadWeaver_LIB_SRCS
TARGET KF5ThreadWeaver
PRODUCT_NAME "KDE Frameworks"
FILE_DESC "ThreadWeaver"
COMPANY_NAME "KDE Community"
VERSION ${THREADWEAVER_VERSION_STRING}
)
#include <winver.h>
1 VERSIONINFO
FILEVERSION @VERSION_COMMAS@
PRODUCTVERSION @VERSION_COMMAS@
FILEFLAGS VS_FF_PRIVATEBUILD
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
{
BLOCK "StringFileInfo" {
BLOCK "040904E4" {
VALUE "CompanyName", "@COMPANYNAME@"
VALUE "FileDescription", "@FILEDESC@"
VALUE "ProductName", "@PRODUCTNAME@"
VALUE "ProductVersion", "@VERSIONSTR@"
VALUE "FileVersion", "@VERSIONSTR@"
}
}
BLOCK "VarFileInfo" {
VALUE "Translation", 0x0, 0x4E4
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment