From 084aebee3547b5eab48015d8b81d2ef42312cef9 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 | 7 +++++++ cmake/dbus/CMakeLists.txt | 11 ++++++----- cmake/tools/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++++++ configure.ac | 4 ++++ dbus/versioninfo.rc.in | 4 ++-- 6 files changed, 55 insertions(+), 7 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..8957f472 100644 --- a/cmake/bus/CMakeLists.txt +++ b/cmake/bus/CMakeLists.txt @@ -88,6 +88,13 @@ include_directories( ${EXPAT_INCLUDE_DIR} ) +if(WIN32) + set(DBUS_INTERNAL_NAME "dbus-daemon") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + 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}) diff --git a/cmake/dbus/CMakeLists.txt b/cmake/dbus/CMakeLists.txt index 8a01d918..1f2a8f22 100644 --- a/cmake/dbus/CMakeLists.txt +++ b/cmake/dbus/CMakeLists.txt @@ -241,11 +241,12 @@ 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}") + 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..a1b2a7af 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -54,15 +54,35 @@ 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}") + 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}") + 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) + set(DBUS_INTERNAL_NAME "dbus-update-activation-environment") + set(DBUS_ORIGIN_INTERNAL_NAME "${DBUS_INTERNAL_NAME}${CMAKE_EXECUTABLE_SUFFIX}") + 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 +95,13 @@ 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}") + 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 +109,13 @@ 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}") + 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..f3ff0a71 100644 --- a/configure.ac +++ b/configure.ac @@ -151,6 +151,10 @@ 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) + 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) 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..ec2a458b 100644 --- a/dbus/versioninfo.rc.in +++ b/dbus/versioninfo.rc.in @@ -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