From 3eaf7223dc2750eb43ece56cca6f96522275fda9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20L=C3=B3pez-Cabanillas?= Date: Tue, 10 Dec 2024 20:14:42 +0100 Subject: [PATCH] Replace VERSIONINFO resource cmake macro (#1449) --- CMakeLists.txt | 2 +- cmake_admin/VersionInfo.in | 79 --------------- cmake_admin/VersionResource.rc | 37 ------- cmake_admin/VersionResource.rc.in | 35 +++++++ cmake_admin/generate_product_version.cmake | 107 --------------------- src/CMakeLists.txt | 30 +++--- 6 files changed, 51 insertions(+), 239 deletions(-) delete mode 100644 cmake_admin/VersionInfo.in delete mode 100644 cmake_admin/VersionResource.rc create mode 100644 cmake_admin/VersionResource.rc.in delete mode 100644 cmake_admin/generate_product_version.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 849f8b376..f1104992a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # FluidSynth - A Software Synthesizer # -# Copyright (C) 2003-2023 Peter Hanappe and others. +# Copyright (C) 2003-2024 Peter Hanappe and others. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License diff --git a/cmake_admin/VersionInfo.in b/cmake_admin/VersionInfo.in deleted file mode 100644 index a6228b454..000000000 --- a/cmake_admin/VersionInfo.in +++ /dev/null @@ -1,79 +0,0 @@ -#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 PRODUCT_VERSION_BUILD -#define PRODUCT_VERSION_BUILD @PRODUCT_VERSION_REVISION@ -#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 FILE_VERSION_BUILD -#define FILE_VERSION_BUILD @PRODUCT_VERSION_REVISION@ -#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_FULL_STR PRODUCT_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(PRODUCT_VERSION_BUILD) -#define PRODUCT_VERSION_RESOURCE PRODUCT_VERSION_MAJOR,PRODUCT_VERSION_MINOR,PRODUCT_VERSION_PATCH,PRODUCT_VERSION_BUILD -#define PRODUCT_VERSION_RESOURCE_STR PRODUCT_VERSION_FULL_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_FULL_STR FILE_VERSION_MAJOR_MINOR_PATCH_STR "." __TO_STRING(FILE_VERSION_BUILD) -#define FILE_VERSION_RESOURCE FILE_VERSION_MAJOR,FILE_VERSION_MINOR,FILE_VERSION_PATCH,FILE_VERSION_BUILD -#define FILE_VERSION_RESOURCE_STR FILE_VERSION_FULL_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 - diff --git a/cmake_admin/VersionResource.rc b/cmake_admin/VersionResource.rc deleted file mode 100644 index 27bc7b309..000000000 --- a/cmake_admin/VersionResource.rc +++ /dev/null @@ -1,37 +0,0 @@ -#include "VersionInfo.h" -#include "winver.h" - -VS_VERSION_INFO VERSIONINFO - FILEVERSION FILE_VERSION_RESOURCE - PRODUCTVERSION PRODUCT_VERSION_RESOURCE - FILEFLAGSMASK VS_FFI_FILEFLAGSMASK -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS VOS__WINDOWS32 - FILETYPE VFT_DLL - FILESUBTYPE VFT2_UNKNOWN -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "040904E4" - 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, 1252 - END -END - diff --git a/cmake_admin/VersionResource.rc.in b/cmake_admin/VersionResource.rc.in new file mode 100644 index 000000000..2c941c336 --- /dev/null +++ b/cmake_admin/VersionResource.rc.in @@ -0,0 +1,35 @@ +#include "winver.h" + +VS_VERSION_INFO VERSIONINFO +FILEVERSION @FLUIDSYNTH_VERSION_MAJOR@, @FLUIDSYNTH_VERSION_MINOR@, @FLUIDSYNTH_VERSION_MICRO@ +PRODUCTVERSION @FLUIDSYNTH_VERSION_MAJOR@, @FLUIDSYNTH_VERSION_MINOR@, @FLUIDSYNTH_VERSION_MICRO@, 0 +#ifdef DEBUG +FILEFLAGS VS_FF_DEBUG +#else +FILEFLAGS 0x0L +#endif +FILEOS VOS__WINDOWS32 +FILETYPE @TARGET_TYPE@ +FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" + BEGIN + VALUE "CompanyName", "FluidSynth" + VALUE "FileDescription", "FluidSynth - A Software Synthesizer" + VALUE "FileVersion", "@FLUIDSYNTH_VERSION_MAJOR@.@FLUIDSYNTH_VERSION_MINOR@.@FLUIDSYNTH_VERSION_MICRO@" + VALUE "Full Version", "@FLUIDSYNTH_VERSION_MAJOR@.@FLUIDSYNTH_VERSION_MINOR@.@FLUIDSYNTH_VERSION_MICRO@.0" + VALUE "InternalName", "FluidSynth" + VALUE "ProductName", "@PRODUCT_NAME@" + VALUE "LegalCopyright", "Copyright (C) 2003-2024 Peter Hanappe and others. Licensed under the terms of the LGPL v2.1" + VALUE "OriginalFilename", "@TARGET_FILENAME@" + VALUE "ProductVersion", "@FLUIDSYNTH_VERSION_MAJOR@.@FLUIDSYNTH_VERSION_MINOR@.@FLUIDSYNTH_VERSION_MICRO@" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END + diff --git a/cmake_admin/generate_product_version.cmake b/cmake_admin/generate_product_version.cmake deleted file mode 100644 index b91fab29f..000000000 --- a/cmake_admin/generate_product_version.cmake +++ /dev/null @@ -1,107 +0,0 @@ -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) -# ICON - path to application icon (${CMAKE_SOURCE_DIR}/product.ico by default) -# VERSION_MAJOR - 1 is default -# VERSION_MINOR - 0 is default -# VERSION_PATCH - 0 is default -# VERSION_REVISION - 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 - VERSION_REVISION - 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_ICON OR "${PRODUCT_ICON}" STREQUAL "") -# set(PRODUCT_ICON "${CMAKE_SOURCE_DIR}/product.ico") -# 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_VERSION_REVISION OR "${PRODUCT_VERSION_REVISION}" STREQUAL "") - set(PRODUCT_VERSION_REVISION 0) - endif() - - if (NOT PRODUCT_COMPANY_COPYRIGHT OR "${PRODUCT_COMPANY_COPYRIGHT}" STREQUAL "") - string(TIMESTAMP PRODUCT_CURRENT_YEAR "%Y") - set(PRODUCT_COMPANY_COPYRIGHT "${PRODUCT_COMPANY_NAME} (C) Copyright ${PRODUCT_CURRENT_YEAR}") - 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() - diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a2f9e55b0..ff7aa34c1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,6 +1,6 @@ # FluidSynth - A Software Synthesizer # -# Copyright (C) 2003-2010 Peter Hanappe and others. +# Copyright (C) 2003-2024 Peter Hanappe and others. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public License @@ -211,20 +211,11 @@ configure_file ( ${FluidSynth_SOURCE_DIR}/include/fluidsynth.cmake ${public_main_HEADER} ) if ( WIN32 ) -include(generate_product_version) -generate_product_version( - VersionFilesOutputVariable - NAME "Fluidsynth" - BUNDLE "Fluidsynth" - VERSION_MAJOR ${FLUIDSYNTH_VERSION_MAJOR} - VERSION_MINOR ${FLUIDSYNTH_VERSION_MINOR} - VERSION_PATCH ${FLUIDSYNTH_VERSION_MICRO} - VERSION_REVISION 0 - COMMENTS "Fluidsynth" - COMPANY_NAME "Fluidsynth LGPL" - ORIGINAL_FILENAME "libfluidsynth.dll" - FILE_DESCRIPTION "Fluidsynth" -) + set(TARGET_TYPE "VFT_DLL") + set(TARGET_FILENAME "libfluidsynth-${LIB_VERSION_CURRENT}.dll") + set(PRODUCT_NAME "FluidSynth Library") + set(VersionFilesOutputVariable "${FluidSynth_BINARY_DIR}/src/VersionInfoLib.rc") + configure_file(${FluidSynth_SOURCE_DIR}/cmake_admin/VersionResource.rc.in ${VersionFilesOutputVariable} @ONLY) endif ( WIN32 ) add_library ( libfluidsynth-OBJ OBJECT @@ -449,8 +440,17 @@ if ( WASAPI_SUPPORT ) set ( fluidsynth_SOURCES ${fluidsynth_SOURCES} fluid_wasapi_device_enumerate.c ) endif ( WASAPI_SUPPORT ) +if ( WIN32 ) + set(TARGET_TYPE "VFT_APP") + set(TARGET_FILENAME "fluidsynth.exe") + set(PRODUCT_NAME "FluidSynth CLI") + set(VersionFilesOutputVariable "${FluidSynth_BINARY_DIR}/src/VersionInfo.rc") + configure_file(${FluidSynth_SOURCE_DIR}/cmake_admin/VersionResource.rc.in ${VersionFilesOutputVariable} @ONLY) +endif ( WIN32 ) + add_executable ( fluidsynth ${fluidsynth_SOURCES} + ${VersionFilesOutputVariable} ) set_target_properties ( fluidsynth