diff --git a/Buildscr b/Buildscr index f6eb4c1..8781b86 100644 --- a/Buildscr +++ b/Buildscr @@ -17,6 +17,7 @@ in puzzles do perl -e 'print "\n\\versionid Simon Tatham'\''s Portable Puzzle Co # Write out a version.h that contains the real version number. in puzzles do echo '/* Generated by automated build script */' > version.h in puzzles do echo '$#define VER "Version $(Version)"' >> version.h +in puzzles do perl -e '$$ARGV[0] =~ m{(....)(..)(..)} or die; print "$#define VERSIONINFO_BINARY_VERSION 1,$$1,$$2,$$3\n"' $(!builddate) >> version.h # And do the same substitution in the OS X metadata. (This is a bit # icky in principle because it presumes that my version numbers don't diff --git a/cmake/platforms/windows.cmake b/cmake/platforms/windows.cmake index 5a0cf18..b34fc09 100644 --- a/cmake/platforms/windows.cmake +++ b/cmake/platforms/windows.cmake @@ -43,10 +43,48 @@ function(set_platform_gui_target_properties TARGET) set_target_properties(${TARGET} PROPERTIES WIN32_EXECUTABLE ON) endfunction() +# Escape a string to make it into a C string literal. Used for textual +# #defines to put into VERSIONINFO resources. +function(c_string_escape outvar value) + string(REPLACE "\\" "\\\\" value "${value}") + string(REPLACE "\"" "\\\"" value "${value}") + set("${outvar}" "${value}" PARENT_SCOPE) +endfunction() + +# Set the character set for resource files, because we're going to use +# a copyright sign in ours. +if(CMAKE_C_COMPILER_ID MATCHES "MSVC" OR + CMAKE_C_COMPILER_FRONTEND_VARIANT MATCHES "MSVC") + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /nologo /C1252") +else() + set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} -c1252") +endif() + +# Get the first line of LICENCE to put into VERSIONINFO resources. +file(READ "${CMAKE_SOURCE_DIR}/LICENCE" LICENCE_TEXT) +set(copyright_regex "This software is copyright ([^\n]*[^\n.])\\.?\n") +string(REGEX MATCH "${copyright_regex}" COPYRIGHT_NOTICE "${LICENCE_TEXT}") +string(REGEX REPLACE "${copyright_regex}" "\\1" + COPYRIGHT_NOTICE "${COPYRIGHT_NOTICE}") +c_string_escape(COPYRIGHT_NOTICE "Copyright ${COPYRIGHT_NOTICE}") +string(REGEX REPLACE "\\([Cc]\\)" "\\\\251" + COPYRIGHT_NOTICE "${COPYRIGHT_NOTICE}") + function(set_platform_puzzle_target_properties NAME TARGET) if(DEFINED ICO_DIR AND EXISTS ${ICO_DIR}/${NAME}.ico) target_compile_definitions(${TARGET} PRIVATE ICON_FILE=\"${ICO_DIR}/${NAME}.ico\") endif() + + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/${NAME}) + c_string_escape(QUOTED_DESCRIPTION "${OPT_DESCRIPTION}") + file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/include/${NAME}/gamedetails.h" "\ +/* #defines for ${name}'s VERSIONINFO */ +#define VERSIONINFO_GAMENAME \"${NAME}\" +#define VERSIONINFO_GAMEDESC \"${QUOTED_DESCRIPTION}\" +#define VERSIONINFO_EXENAME \"${TARGET}\" +#define VERSIONINFO_COPYRIGHT \"${COPYRIGHT_NOTICE}\" +") + target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/include/${NAME}) endfunction() function(build_platform_extras) diff --git a/cmake/toolchain-mingw.cmake b/cmake/toolchain-mingw.cmake index 68ee249..a00fc7d 100644 --- a/cmake/toolchain-mingw.cmake +++ b/cmake/toolchain-mingw.cmake @@ -8,5 +8,3 @@ set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) set(CMAKE_AR x86_64-w64-mingw32-ar) set(CMAKE_RANLIB x86_64-w64-mingw32-ranlib) - -add_compile_definitions(MINGW32_FIX) diff --git a/puzzles.rc b/puzzles.rc index d566478..3f5d137 100644 --- a/puzzles.rc +++ b/puzzles.rc @@ -1,12 +1,39 @@ /* Windows resource file for all puzzles. */ +#include "version.h" +#include "gamedetails.h" + #if defined ICON_FILE 200 ICON ICON_FILE -#else -#ifdef MINGW32_FIX -/* XXX The MinGW toolchain (specifically, windres) doesn't like a resource - * file with no resources. Give it a dummy one. - * This can go if/when VERSIONINFO resources are added. */ -200 RCDATA { 0 } -#endif #endif + +1 VERSIONINFO +FILEVERSION VERSIONINFO_BINARY_VERSION /* version of this file */ +PRODUCTVERSION VERSIONINFO_BINARY_VERSION /* version of whole suite */ +FILEFLAGSMASK 0 +FILEFLAGS 0 +FILEOS 4 /* Win32 */ +FILETYPE 1 /* application */ +FILESUBTYPE 0 /* applications have no subtypes */ +BEGIN + BLOCK "StringFileInfo" + BEGIN + /* "lang-charset" LLLLCCCC = (UK English, Unicode) */ + BLOCK "080904B0" + BEGIN + VALUE "CompanyName", L"Simon Tatham" + VALUE "ProductName", L"Portable Puzzle Collection" + VALUE "FileDescription", VERSIONINFO_GAMEDESC + VALUE "InternalName", VERSIONINFO_GAMENAME + VALUE "OriginalFilename", VERSIONINFO_EXENAME + VALUE "FileVersion", VER + VALUE "ProductVersion", VER + VALUE "LegalCopyright", VERSIONINFO_COPYRIGHT + END + END + BLOCK "VarFileInfo" + BEGIN + /* Once again -- same meanings -- apparently necessary */ + VALUE "Translation", 0x809, 1200 + END +END diff --git a/version.h b/version.h index 997e005..20d2800 100644 --- a/version.h +++ b/version.h @@ -9,3 +9,5 @@ */ #define VER "Unidentified build" + +#define VERSIONINFO_BINARY_VERSION 0,0,0,0