Skip to content

Commit

Permalink
feat(win): Add binary meta (hyperion-project#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
brindosch committed Aug 2, 2020
1 parent 8824e69 commit 94c2365
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 14 deletions.
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion cmake/nsis/icon.rc

This file was deleted.

34 changes: 34 additions & 0 deletions cmake/win/win.rc.in
Original file line number Diff line number Diff line change
@@ -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 changes: 15 additions & 0 deletions cmake/win/win_rc.cmake
Original file line number Diff line number Diff line change
@@ -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()
8 changes: 7 additions & 1 deletion src/hyperion-qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 7 additions & 1 deletion src/hyperion-remote/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
13 changes: 12 additions & 1 deletion src/hyperiond/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,27 @@ 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
systray.h
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
Expand Down

0 comments on commit 94c2365

Please sign in to comment.