diff options
Diffstat (limited to 'cmake')
| -rw-r--r-- | cmake/platforms/windows.cmake | 38 | ||||
| -rw-r--r-- | cmake/toolchain-mingw.cmake | 2 |
2 files changed, 38 insertions, 2 deletions
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) |