Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] Add windows resource file for application icon and metadata #384

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ include(conan_setup)

# The marked constants in application.hpp will be replaced with the following values
set(INEXOR_ENGINE_NAME "Inexor Engine")
set(INEXOR_DEV_TEAM_NAME "Inexor Collective")
set(INEXOR_APP_NAME "Inexor Vulkan-renderer example")
set(INEXOR_LICENSE "MIT License")

set(INEXOR_ENGINE_VERSION_MAJOR 0)
set(INEXOR_ENGINE_VERSION_MINOR 1)
Expand All @@ -60,8 +62,13 @@ execute_process(
)

add_subdirectory(shaders)

add_subdirectory(src)

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

if(INEXOR_BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
Expand Down
11 changes: 10 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
add_executable(inexor-vulkan-renderer-example main.cpp)
if(MSVC)
add_executable(inexor-vulkan-renderer-example
main.cpp
${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/win_resource_file.rc
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source files shouldn't be in the include folder.

)
else()
add_executable(inexor-vulkan-renderer-example
main.cpp
)
endif()

set_target_properties(
inexor-vulkan-renderer-example PROPERTIES
Expand Down
12 changes: 7 additions & 5 deletions include/inexor/vulkan-renderer/meta.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ namespace inexor::vulkan_renderer {

/// The following data will be replaced by CMake setup.
constexpr const char *APP_NAME{"${INEXOR_APP_NAME}"};
constexpr std::array<std::uint32_t, 3> APP_VERSION{${INEXOR_APP_VERSION_MAJOR}, ${INEXOR_APP_VERSION_MINOR},
${INEXOR_APP_VERSION_PATCH}};
constexpr std::array<std::uint32_t, 3> APP_VERSION{${INEXOR_APP_VERSION_MAJOR}, ${INEXOR_APP_VERSION_MINOR}, ${INEXOR_APP_VERSION_PATCH}};
constexpr const char *APP_VERSION_STR{"${INEXOR_APP_VERSION_MAJOR}.${INEXOR_APP_VERSION_MINOR}.${INEXOR_APP_VERSION_PATCH}"};
constexpr const char* ENGINE_NAME{"${INEXOR_ENGINE_NAME}"};
constexpr std::array<std::uint32_t, 3> ENGINE_VERSION{${INEXOR_ENGINE_VERSION_MAJOR}, ${INEXOR_ENGINE_VERSION_MINOR},
${INEXOR_ENGINE_VERSION_PATCH}};
constexpr std::array<std::uint32_t, 3> ENGINE_VERSION{${INEXOR_ENGINE_VERSION_MAJOR}, ${INEXOR_ENGINE_VERSION_MINOR}, ${INEXOR_ENGINE_VERSION_PATCH}};
constexpr const char *ENGINE_VERSION_STR{"${INEXOR_ENGINE_VERSION_MAJOR}.${INEXOR_ENGINE_VERSION_MINOR}.${INEXOR_ENGINE_VERSION_PATCH}"};
constexpr const char *BUILD_GIT = "${INEXOR_GIT_SHA}";
constexpr const char *BUILD_TYPE = "${CMAKE_BUILD_TYPE}";
#ifdef NDEBUG
constexpr const char *BUILD_TYPE = "Release";
#else
constexpr const char *BUILD_TYPE = "Debug";
#endif

} // namespace inexor::vulkan_renderer
1 change: 1 addition & 0 deletions platform/windows/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
configure_file(win_resource_file.rc.in ${CMAKE_BINARY_DIR}/include/inexor/vulkan-renderer/win_resource_file.rc)
Binary file added platform/windows/inexor_icon_256px.ico
Binary file not shown.
40 changes: 40 additions & 0 deletions platform/windows/win_resource_file.rc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#define APSTUDIO_READONLY_SYMBOLS
#include "winres.h"
#undef APSTUDIO_READONLY_SYMBOLS

VS_VERSION_INFO VERSIONINFO
FILEVERSION ${INEXOR_APP_VERSION_MAJOR},${INEXOR_APP_VERSION_MINOR},${INEXOR_APP_VERSION_PATCH},0
PRODUCTVERSION ${INEXOR_ENGINE_VERSION_MAJOR},${INEXOR_ENGINE_VERSION_MINOR},${INEXOR_ENGINE_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", "${INEXOR_DEV_TEAM_NAME}"
VALUE "FileDescription", "${INEXOR_APP_NAME}"
VALUE "FileVersion", "${INEXOR_APP_VERSION_MAJOR}.${INEXOR_APP_VERSION_MINOR}.${INEXOR_APP_VERSION_PATCH}"
VALUE "InternalName", "${INEXOR_ENGINE_NAME}"
VALUE "LegalCopyright", "${INEXOR_LICENSE}"
VALUE "OriginalFilename", "${INEXOR_APP_NAME}"
VALUE "ProductName", "${INEXOR_APP_NAME}"
VALUE "ProductVersion", "${INEXOR_ENGINE_VERSION_MAJOR}.${INEXOR_ENGINE_VERSION_MINOR}.${INEXOR_ENGINE_VERSION_PATCH}"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0409, 1200
END
END

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