Skip to content

Commit 7090fac

Browse files
committed
[cmake] Add windows resource file for application icon and metadata
1 parent 9ed238a commit 7090fac

File tree

6 files changed

+81
-1
lines changed

6 files changed

+81
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ find_package(Vulkan REQUIRED)
3434
include(conan_setup)
3535

3636
add_subdirectory(shaders)
37+
38+
if(MSVC)
39+
add_subdirectory(platform/windows)
40+
endif()
41+
3742
add_subdirectory(src)
3843

3944
if(INEXOR_BUILD_BENCHMARKS)

example/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
add_executable(inexor-vulkan-renderer-example main.cpp)
1+
add_executable(inexor-vulkan-renderer-example
2+
main.cpp
3+
# Windows resource file to set application icon and metadata
4+
${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/resource.hpp
5+
${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/win_resource_file.rc
6+
)
27

38
set_target_properties(
49
inexor-vulkan-renderer-example PROPERTIES

platform/windows/CMakeLists.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
set(APP_MANUFACTURER_NAME "Inexor collective")
2+
set(APP_DESCRIPTION "Inexor vulkan-renderer")
3+
set(APP_NAME "Inexor engine")
4+
set(APP_LICENSE "MIT License")
5+
set(APP_ORIGINAL_NAME "Inexor vulkan renderer example")
6+
set(APP_VERSION_MAJOR 1)
7+
set(APP_VERSION_MINOR 0)
8+
set(APP_VERSION_PATCH 0)
9+
10+
# Replace variables in resource file with CMake values
11+
configure_file(
12+
win_resource_file.rc.in ${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/win_resource_file.rc
13+
)
14+
15+
configure_file(
16+
resource.hpp.in ${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/resource.hpp
17+
)
21.1 KB
Binary file not shown.

platform/windows/resource.hpp.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Specify icon from resource file as icon of executable
2+
#define IDI_ICON1 105
3+
4+
#ifdef APSTUDIO_INVOKED
5+
#ifndef APSTUDIO_READONLY_SYMBOLS
6+
#define _APS_NEXT_RESOURCE_VALUE 106
7+
#define _APS_NEXT_COMMAND_VALUE 40001
8+
#define _APS_NEXT_CONTROL_VALUE 1001
9+
#define _APS_NEXT_SYMED_VALUE 101
10+
#endif
11+
#endif
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#include "resource.hpp"
2+
3+
#define APSTUDIO_READONLY_SYMBOLS
4+
#include "winres.h"
5+
#undef APSTUDIO_READONLY_SYMBOLS
6+
7+
VS_VERSION_INFO VERSIONINFO
8+
FILEVERSION ${APP_VERSION_MAJOR},${APP_VERSION_MINOR},${APP_VERSION_PATCH},0
9+
PRODUCTVERSION ${APP_VERSION_MAJOR},${APP_VERSION_MINOR},${APP_VERSION_PATCH},0
10+
FILEFLAGSMASK 0x3fL
11+
#ifdef _DEBUG
12+
FILEFLAGS 0x1L
13+
#else
14+
FILEFLAGS 0x0L
15+
#endif
16+
FILEOS 0x40004L
17+
FILETYPE 0x1L
18+
FILESUBTYPE 0x0L
19+
BEGIN
20+
BLOCK "StringFileInfo"
21+
BEGIN
22+
BLOCK "040704b0"
23+
BEGIN
24+
// These placeholders will be filled out with the values specified by CMake
25+
VALUE "CompanyName", "${APP_MANUFACTURER_NAME}"
26+
VALUE "FileDescription", "${APP_DESCRIPTION}"
27+
VALUE "FileVersion", "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}"
28+
VALUE "InternalName", "${APP_NAME}"
29+
VALUE "LegalCopyright", "${APP_LICENSE}"
30+
VALUE "OriginalFilename", "${APP_ORIGINAL_NAME}"
31+
VALUE "ProductName", "${APP_NAME}"
32+
VALUE "ProductVersion", "${APP_VERSION_MAJOR}.${APP_VERSION_MINOR}.${APP_VERSION_PATCH}"
33+
END
34+
END
35+
BLOCK "VarFileInfo"
36+
BEGIN
37+
VALUE "Translation", 0x407, 1200
38+
END
39+
END
40+
41+
// Use Inexor logo as icon for executable
42+
IDI_ICON1 ICON "${PROJECT_SOURCE_DIR}\\platform\\windows\\inexor_icon_256px.ico"

0 commit comments

Comments
 (0)