From 75ecdef3e82005395e84fc3acf286b178eb1173a Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 18 Oct 2017 23:19:52 +0200 Subject: [PATCH] Add version info to installed executables for cmake build system on Windows Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103387 Signed-off-by: Ralf Habacker --- cmake/CMakeLists.txt | 2 ++ cmake/bus/CMakeLists.txt | 19 ++++++++++++++++--- cmake/dbus/CMakeLists.txt | 17 ++++++++++------- cmake/tools/CMakeLists.txt | 40 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 7 +++++++ dbus/versioninfo.rc.in | 6 +++--- 6 files changed, 78 insertions(+), 13 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 3ac71a5a..bbcfb93f 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -44,6 +44,8 @@ autopackage( include(Macros) string(TIMESTAMP DBUS_BUILD_TIMESTAMP "%Y%m%d%H%M" UTC) +set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION}) +set (BUILD_TIMESTAMP ${DBUS_BUILD_TIMESTAMP}) ########### basic vars ############### diff --git a/cmake/bus/CMakeLists.txt b/cmake/bus/CMakeLists.txt index 4c5bdcf2..bfc46fed 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -88,6 +88,14 @@ include_directories( ${EXPAT_INCLUDE_DIR} ) +if(WIN32) + set(DBUS_VER_INTERNAL_NAME "dbus-daemon") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND BUS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) +endif() + add_executable(dbus-daemon ${BUS_SOURCES} ${BUS_DIR}/main.c) target_link_libraries(dbus-daemon ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES}) set_target_properties(dbus-daemon PROPERTIES OUTPUT_NAME ${DBUS_DAEMON_NAME}) @@ -108,13 +116,18 @@ if(NOT WIN32) endif() if (DBUS_SERVICE) - set (dbus_service_SOURCES - ${BUS_DIR}/bus-service-win.c + set (dbus_service_SOURCES + ${BUS_DIR}/bus-service-win.c # TODO: add additional files # ${BUS_DIR}/service-main.c - # ${BUS_SOURCES} + # ${BUS_SOURCES} ) + set(DBUS_VER_INTERNAL_NAME "dbus-service") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND dbus_service_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) add_executable(dbus-service ${dbus_service_SOURCES} ) target_link_libraries(dbus-service ${DBUS_INTERNAL_LIBRARIES} ${EXPAT_LIBRARIES}) set_target_properties(dbus-service PROPERTIES COMPILE_FLAGS ${DBUS_INTERNAL_CLIENT_DEFINITIONS}) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 2fdd1128..ef81cf27 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -243,11 +243,17 @@ set(libdbus_HEADERS ${DBUS_SHARED_HEADERS} ) -set (BUILD_FILEVERSION ${DBUS_MAJOR_VERSION},${DBUS_MINOR_VERSION},${DBUS_MICRO_VERSION},${DBUS_PATCH_VERSION}) -set (BUILD_TIMESTAMP ${DBUS_BUILD_TIMESTAMP}) +if(DEFINED DBUS_LIBRARY_REVISION) + math(EXPR DBUS_LIBRARY_MAJOR "${DBUS_LIBRARY_CURRENT} - ${DBUS_LIBRARY_AGE}") +endif() -configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc) -list(APPEND libdbus_SOURCES versioninfo.rc) +if(WIN32) + set(DBUS_VER_INTERNAL_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}dbus-1-${DBUS_LIBRARY_MAJOR}") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_DLL") + configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc) + list(APPEND libdbus_SOURCES versioninfo.rc) +endif() if(MSVC_IDE) project_source_group(${GROUP_CODE} DBUS_LIB_SOURCES DBUS_LIB_HEADERS) @@ -266,9 +272,6 @@ add_library(dbus-1 SHARED ${libdbus_SOURCES} ${libdbus_HEADERS} ) -if(DEFINED DBUS_LIBRARY_REVISION) - math(EXPR DBUS_LIBRARY_MAJOR "${DBUS_LIBRARY_CURRENT} - ${DBUS_LIBRARY_AGE}") -endif() if(WIN32) if(DEFINED DBUS_LIBRARY_REVISION) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index c05ced43..09270cb4 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -54,14 +54,38 @@ set (dbus_cleanup_sockets_SOURCES ../../tools/dbus-cleanup-sockets.c ) +if(WIN32) + set(DBUS_VER_INTERNAL_NAME "dbus-send") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND dbus_send_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) +endif() + add_executable(dbus-send ${dbus_send_SOURCES}) target_link_libraries(dbus-send ${DBUS_LIBRARIES}) install(TARGETS dbus-send ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(WIN32) + set(DBUS_VER_INTERNAL_NAME "dbus-test-tool") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND dbus_test_tool_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) +endif() + add_executable(dbus-test-tool ${dbus_test_tool_SOURCES}) target_link_libraries(dbus-test-tool ${DBUS_LIBRARIES}) install(TARGETS dbus-test-tool ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(WIN32) + # version info and uac manifest can be combined in a binary because they use different resource types + set(DBUS_VER_INTERNAL_NAME "dbus-update-activation-environment") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND dbus_update_activation_environment_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) +endif() if(WIN32 AND NOT MSVC) # avoid dbus-update-activation-environment triggering UAC # 1 is the resource ID, ID_MANIFEST @@ -75,6 +99,14 @@ add_executable(dbus-update-activation-environment ${dbus_update_activation_envir target_link_libraries(dbus-update-activation-environment ${DBUS_LIBRARIES}) install(TARGETS dbus-update-activation-environment ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(WIN32) + set(DBUS_VER_INTERNAL_NAME "dbus-launch") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND dbus_launch_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) +endif() + add_executable(dbus-launch ${dbus_launch_SOURCES}) target_link_libraries(dbus-launch ${DBUS_LIBRARIES}) if (DBUS_BUILD_X11) @@ -82,6 +114,14 @@ if (DBUS_BUILD_X11) endif (DBUS_BUILD_X11) install(TARGETS dbus-launch ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(WIN32) + set(DBUS_VER_INTERNAL_NAME "dbus-monitor") + set(DBUS_VER_ORIGINAL_NAME "${DBUS_VER_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_VER_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) + list(APPEND dbus_monitor_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_VER_INTERNAL_NAME}.rc) +endif() + add_executable(dbus-monitor ${dbus_monitor_SOURCES}) target_link_libraries(dbus-monitor ${DBUS_LIBRARIES}) install(TARGETS dbus-monitor ${INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/configure.ac b/configure.ac index ce1f2c56..7130e312 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,13 @@ if test "$dbus_win" = yes; then # Assume DBUS_VERSION is always three numbers BUILD_FILEVERSION=`echo "$DBUS_VERSION" | sed -e 's/\./,/g'`,0 AC_SUBST(BUILD_FILEVERSION) + # In the CMake build system we generate multiple files, versioninfo-*.rc, with a + # different "internal name" and "original filename", for embedding in multiple + # executables. In the Autotools build system, we currently only generate + # versioninfo.rc and embed it in libdbus-1-${SOVERSION}.dll. + AC_SUBST([DBUS_VER_INTERNAL_NAME], [libdbus-1-${SOVERSION}]) + AC_SUBST([DBUS_VER_ORIGINAL_NAME], [libdbus-1-${SOVERSION}.dll]) + AC_SUBST([DBUS_VER_FILE_TYPE], [VFT_DLL]) AS_IF([test -z "$RC"], [AC_MSG_ERROR([An implementation of windres is required])]) if test "$dbus_wince" = yes; then diff --git a/dbus/versioninfo.rc.in b/dbus/versioninfo.rc.in index 4af2beee..7f09b105 100644 --- a/dbus/versioninfo.rc.in +++ b/dbus/versioninfo.rc.in @@ -24,7 +24,7 @@ VS_VERSION_INFO VERSIONINFO FILEFLAGS 0x0L #endif FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL + FILETYPE @DBUS_VER_FILE_TYPE@ FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" @@ -36,10 +36,10 @@ BEGIN VALUE "CompanyName", "freedesktop.org\0" VALUE "FileDescription", "dbus - FreeDesktop message bus system\0" VALUE "FileVersion", "@DBUS_VERSION@\0" - VALUE "InternalName", "libdbus-1-3\0" + VALUE "InternalName", "@DBUS_VER_INTERNAL_NAME@\0" VALUE "LegalCopyright", "Copyright © 1994-2017 dbus contributors, see dbus source code for details\0" VALUE "LegalTrademarks", "\0" - VALUE "OriginalFilename", "libdbus-1-3.dll\0" + VALUE "OriginalFilename", "@DBUS_VER_ORIGINAL_NAME@\0" VALUE "ProductName", "dbus\0" VALUE "ProductVersion", "@DBUS_VERSION@\0" VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0" -- 2.12.3