From 0278fb700d5800b9a292606e45423fad2d66a1f5 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=103015 --- cmake/CMakeLists.txt | 2 ++ cmake/bus/CMakeLists.txt | 34 +++++++++++++++++++++++----------- cmake/dbus/CMakeLists.txt | 12 +++++++----- cmake/tools/CMakeLists.txt | 38 ++++++++++++++++++++++++++++++++++++++ configure.ac | 10 ++++++++++ dbus/versioninfo.rc.in | 6 +++--- 6 files changed, 83 insertions(+), 19 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..b37aa9fe 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -88,6 +88,14 @@ include_directories( ${EXPAT_INCLUDE_DIR} ) +if(WIN32) + set(DBUS_INTERNAL_NAME "dbus-daemon") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND BUS_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_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,17 +116,21 @@ if(NOT WIN32) endif() if (DBUS_SERVICE) - set (dbus_service_SOURCES - ${BUS_DIR}/bus-service-win.c - # TODO: add additional files - # ${BUS_DIR}/service-main.c - # ${BUS_SOURCES} - ) - - 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}) - install(TARGETS dbus-service ${INSTALL_TARGETS_DEFAULT_ARGS}) + set (dbus_service_SOURCES + ${BUS_DIR}/bus-service-win.c + # TODO: add additional files + # ${BUS_DIR}/service-main.c + # ${BUS_SOURCES} + ) + set(DBUS_INTERNAL_NAME "dbus-service") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND dbus_service_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_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}) + install(TARGETS dbus-service ${INSTALL_TARGETS_DEFAULT_ARGS}) endif (DBUS_SERVICE) set(LAUNCH_HELPER_SOURCES diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 8a01d918..46fa7c38 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -241,11 +241,13 @@ 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}) - -configure_file(${DBUS_DIR}/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo.rc) -list(APPEND libdbus_SOURCES versioninfo.rc) +if(WIN32) + set(DBUS_INTERNAL_NAME "${CMAKE_SHARED_LIBRARY_PREFIX}dbus-1-3") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}") + set(DBUS_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) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 5613269e..b430ce7e 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -54,15 +54,37 @@ set (dbus_cleanup_sockets_SOURCES ../../tools/dbus-cleanup-sockets.c ) +if(WIN32) + set(DBUS_INTERNAL_NAME "dbus-send") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND dbus_send_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_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_INTERNAL_NAME "dbus-test-tool") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND dbus_test_tool_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_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_INTERNAL_NAME "dbus-update-activation-environment") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND dbus_update_activation_environment_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) # avoid dbus-update-activation-environment triggering UAC # 1 is the resource ID, ID_MANIFEST # 24 is the resource type, RT_MANIFEST @@ -75,6 +97,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_INTERNAL_NAME "dbus-launch") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND dbus_launch_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) +endif() + add_executable(dbus-launch ${dbus_launch_SOURCES}) target_link_libraries(dbus-launch ${DBUS_LIBRARIES}) if (DBUS_BUILD_X11) @@ -82,6 +112,14 @@ if (DBUS_BUILD_X11) endif (DBUS_BUILD_X11) install(TARGETS dbus-launch ${INSTALL_TARGETS_DEFAULT_ARGS}) +if(WIN32) + set(DBUS_INTERNAL_NAME "dbus-monitor") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + set(DBUS_FILE_TYPE "VFT_APP") + configure_file(${CMAKE_SOURCE_DIR}/../dbus/versioninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_INTERNAL_NAME}.rc) + list(APPEND dbus_monitor_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/versioninfo-${DBUS_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 fed2ba09..42ba116c 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,16 @@ 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-3.dll. + DBUS_INTERNAL_NAME=libdbus-1-3 + AC_SUBST(DBUS_INTERNAL_NAME) + DBUS_ORIGIN_INTERNAL_NAME=libdbus-1-3.dll + AC_SUBST(DBUS_ORIGIN_INTERNAL_NAME) + DBUS_FILE_TYPE=VFT_DLL + AC_SUBST(DBUS_FILE_TYPE) 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..b3011df9 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_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_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_ORIGIN_INTERNAL_NAME@\0" VALUE "ProductName", "dbus\0" VALUE "ProductVersion", "@DBUS_VERSION@\0" VALUE "SpecialBuild", "@BUILD_TIMESTAMP@\0" -- 2.12.3