feat(win): Add binary meta (#932)

This commit is contained in:
brindosch 2020-08-02 22:05:53 +02:00 committed by GitHub
parent 8824e69986
commit 94c23653de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 14 deletions

View File

@ -296,16 +296,6 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
endif()
endif()
# Windows specific
if(WIN32)
# Path to .rc icon file for add_executable() calls
SET ( WIN_RC_ICON_FILE ${CMAKE_SOURCE_DIR}/cmake/nsis/icon.rc)
# Force gui app
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -v")
# Use GNU gold linker if available
if (NOT WIN32)
include (${CMAKE_CURRENT_SOURCE_DIR}/cmake/LDGold.cmake)

View File

@ -1 +0,0 @@
IDI_ICON1 ICON DISCARDABLE "installer.ico"

34
cmake/win/win.rc.in Normal file
View File

@ -0,0 +1,34 @@
IDI_ICON1 ICON DISCARDABLE "${WIN_RC_ICON_PATH}"
1 VERSIONINFO
FILEVERSION ${HYPERION_VERSION_MAJOR},${HYPERION_VERSION_MINOR},${HYPERION_VERSION_PATCH},0
PRODUCTVERSION ${HYPERION_VERSION_MAJOR},${HYPERION_VERSION_MINOR},${HYPERION_VERSION_PATCH},0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x1L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "hyperion-project"
VALUE "Comments", "www.hyperion-project.org"
VALUE "FileDescription", "Hyperion Ambient Lighting"
VALUE "FileVersion", "${HYPERION_VERSION}"
VALUE "InternalName", "Hyperion"
VALUE "LegalCopyright", "MIT"
VALUE "OriginalFilename", "${BINARY_NAME}"
VALUE "ProductName", "Hyperion Ambient Lighting"
VALUE "ProductVersion", "${HYPERION_VERSION}"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END

15
cmake/win/win_rc.cmake Normal file
View File

@ -0,0 +1,15 @@
# process a .rc file for windows
# Provides (BINARY_NAME)_WIN_RC_PATH with path to generated file
function(generate_win_rc_file BINARY_NAME)
# target path to store generated files
set(TARGET_PATH ${CMAKE_BINARY_DIR}/win_rc_file/${BINARY_NAME})
# assets
string(REPLACE "/" "\\\\" WIN_RC_ICON_PATH ${CMAKE_SOURCE_DIR}/cmake/nsis/installer.ico)
# configure the rc file
configure_file(
${CMAKE_SOURCE_DIR}/cmake/win/win.rc.in
${TARGET_PATH}/win.rc
)
# provide var for parent scope
set(${BINARY_NAME}_WIN_RC_PATH ${TARGET_PATH}/win.rc PARENT_SCOPE)
endfunction()

View File

@ -17,10 +17,16 @@ set(Hyperion_QT_SOURCES
hyperion-qt.cpp
)
# generate windows .rc file for this binary
if (WIN32)
include(${CMAKE_SOURCE_DIR}/cmake/win/win_rc.cmake)
generate_win_rc_file(${PROJECT_NAME})
endif()
add_executable(${PROJECT_NAME}
${Hyperion_QT_HEADERS}
${Hyperion_QT_SOURCES}
${WIN_RC_ICON_FILE}
${${PROJECT_NAME}_WIN_RC_PATH}
)
target_link_libraries(${PROJECT_NAME}

View File

@ -17,10 +17,16 @@ set(hyperion-remote_SOURCES
hyperion-remote.cpp
JsonConnection.cpp)
# generate windows .rc file for this binary
if (WIN32)
include(${CMAKE_SOURCE_DIR}/cmake/win/win_rc.cmake)
generate_win_rc_file(${PROJECT_NAME})
endif()
add_executable(${PROJECT_NAME}
${hyperion-remote_HEADERS}
${hyperion-remote_SOURCES}
${WIN_RC_ICON_FILE}
${${PROJECT_NAME}_WIN_RC_PATH}
)
target_link_libraries(${PROJECT_NAME}

View File

@ -8,6 +8,12 @@ endif()
find_package(Qt5Widgets REQUIRED)
# generate windows .rc file for this binary
if (WIN32)
include(${CMAKE_SOURCE_DIR}/cmake/win/win_rc.cmake)
generate_win_rc_file(hyperiond)
endif()
add_executable(hyperiond
console.h
hyperiond.h
@ -15,9 +21,14 @@ add_executable(hyperiond
hyperiond.cpp
systray.cpp
main.cpp
${WIN_RC_ICON_FILE}
${hyperiond_WIN_RC_PATH}
)
# promote hyperiond as GUI app
if (WIN32)
target_link_options(hyperiond PUBLIC /SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup)
endif()
target_link_libraries(hyperiond
commandline
hyperion