Skip to content

Commit

Permalink
[cmake] Add windows resource file for application icon and metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmNotHanni committed May 3, 2021
1 parent 9ed238a commit 7090fac
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ find_package(Vulkan REQUIRED)
include(conan_setup)

add_subdirectory(shaders)

if(MSVC)
add_subdirectory(platform/windows)
endif()

add_subdirectory(src)

if(INEXOR_BUILD_BENCHMARKS)
Expand Down
7 changes: 6 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
add_executable(inexor-vulkan-renderer-example main.cpp)
add_executable(inexor-vulkan-renderer-example
main.cpp
# Windows resource file to set application icon and metadata
${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/resource.hpp
${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/win_resource_file.rc
)

set_target_properties(
inexor-vulkan-renderer-example PROPERTIES
Expand Down
17 changes: 17 additions & 0 deletions platform/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
set(APP_MANUFACTURER_NAME "Inexor collective")
set(APP_DESCRIPTION "Inexor vulkan-renderer")
set(APP_NAME "Inexor engine")
set(APP_LICENSE "MIT License")
set(APP_ORIGINAL_NAME "Inexor vulkan renderer example")
set(APP_VERSION_MAJOR 1)
set(APP_VERSION_MINOR 0)
set(APP_VERSION_PATCH 0)

# Replace variables in resource file with CMake values
configure_file(
win_resource_file.rc.in ${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/win_resource_file.rc
)

configure_file(
resource.hpp.in ${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/resource.hpp
)
Binary file added platform/windows/inexor_icon_256px.ico
Binary file not shown.
11 changes: 11 additions & 0 deletions platform/windows/resource.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Specify icon from resource file as icon of executable
#define IDI_ICON1 105

#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 106
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
42 changes: 42 additions & 0 deletions platform/windows/win_resource_file.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "resource.hpp"

#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"
#undef APSTUDIO_READONLY_SYMBOLS

VS_VERSION_INFO VERSIONINFO
FILEVERSION ${APP_VERSION_MAJOR},${APP_VERSION_MINOR},${APP_VERSION_PATCH},0
PRODUCTVERSION ${APP_VERSION_MAJOR},${APP_VERSION_MINOR},${APP_VERSION_PATCH},0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040704b0"
BEGIN
// These placeholders will be filled out with the values specified by CMake
VALUE "CompanyName", "${APP_MANUFACTURER_NAME}"
VALUE "FileDescription", "${APP_DESCRIPTION}"
VALUE "FileVersion", "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}"
VALUE "InternalName", "${APP_NAME}"
VALUE "LegalCopyright", "${APP_LICENSE}"
VALUE "OriginalFilename", "${APP_ORIGINAL_NAME}"
VALUE "ProductName", "${APP_NAME}"
VALUE "ProductVersion", "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x407, 1200
END
END

// Use Inexor logo as icon for executable
IDI_ICON1 ICON "${PROJECT_SOURCE_DIR}\\platform\\windows\\inexor_icon_256px.ico"

0 comments on commit 7090fac

Please sign in to comment.