diff --git a/CMakeLists.txt b/CMakeLists.txt index 04243027..7a6b7c81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/cmake/nsis/icon.rc b/cmake/nsis/icon.rc deleted file mode 100644 index 69b599db..00000000 --- a/cmake/nsis/icon.rc +++ /dev/null @@ -1 +0,0 @@ -IDI_ICON1 ICON DISCARDABLE "installer.ico" diff --git a/cmake/win/win.rc.in b/cmake/win/win.rc.in new file mode 100644 index 00000000..1eb30542 --- /dev/null +++ b/cmake/win/win.rc.in @@ -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 diff --git a/cmake/win/win_rc.cmake b/cmake/win/win_rc.cmake new file mode 100644 index 00000000..203e3794 --- /dev/null +++ b/cmake/win/win_rc.cmake @@ -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() diff --git a/src/hyperion-qt/CMakeLists.txt b/src/hyperion-qt/CMakeLists.txt index b54837e1..e2d3ca1d 100644 --- a/src/hyperion-qt/CMakeLists.txt +++ b/src/hyperion-qt/CMakeLists.txt @@ -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} diff --git a/src/hyperion-remote/CMakeLists.txt b/src/hyperion-remote/CMakeLists.txt index ea8d8c1c..e39a8116 100644 --- a/src/hyperion-remote/CMakeLists.txt +++ b/src/hyperion-remote/CMakeLists.txt @@ -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} diff --git a/src/hyperiond/CMakeLists.txt b/src/hyperiond/CMakeLists.txt index 9a417d8e..1ad587c8 100644 --- a/src/hyperiond/CMakeLists.txt +++ b/src/hyperiond/CMakeLists.txt @@ -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