summary refs log tree commit diff
path: root/cmake
diff options
context:
space:
mode:
authorMarcel <MTRNord@users.noreply.github.com>2017-11-06 16:17:21 +0100
committermujx <mujx@users.noreply.github.com>2017-11-06 17:17:21 +0200
commit4ba1f2ea837f46607ec1738496ca546babd6b207 (patch)
tree6ffc880107627cc38ee87c78f325bd819a32f7e6 /cmake
parentUpdate README (diff)
downloadnheko-4ba1f2ea837f46607ec1738496ca546babd6b207.tar.xz
Windows icon fix and change the installer to QT Installer Framework on Windows (#85)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/MacOSXBundleInfo.plist.in36
-rw-r--r--cmake/QtCommon.cmake76
-rw-r--r--cmake/windows_metafile.rc.in28
3 files changed, 140 insertions, 0 deletions
diff --git a/cmake/MacOSXBundleInfo.plist.in b/cmake/MacOSXBundleInfo.plist.in
new file mode 100644
index 00000000..7391a6fa
--- /dev/null
+++ b/cmake/MacOSXBundleInfo.plist.in
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+    <key>CFBundleDevelopmentRegion</key>
+    <string>English</string>
+    <key>CFBundleExecutable</key>
+    <string>${MACOSX_BUNDLE_EXECUTABLE_NAME}</string>
+    <key>CFBundleGetInfoString</key>
+    <string>${MACOSX_BUNDLE_INFO_STRING}</string>
+    <key>CFBundleIconFile</key>
+    <string>${MACOSX_BUNDLE_ICON_FILE}</string>
+    <key>CFBundleIdentifier</key>
+    <string>${MACOSX_BUNDLE_GUI_IDENTIFIER}</string>
+    <key>CFBundleInfoDictionaryVersion</key>
+    <string>6.0</string>
+    <key>CFBundleLongVersionString</key>
+    <string>${MACOSX_BUNDLE_LONG_VERSION_STRING}</string>
+    <key>CFBundleName</key>
+    <string>${MACOSX_BUNDLE_BUNDLE_NAME}</string>
+    <key>CFBundlePackageType</key>
+    <string>APPL</string>
+    <key>CFBundleShortVersionString</key>
+    <string>${MACOSX_BUNDLE_SHORT_VERSION_STRING}</string>
+    <key>CFBundleVersion</key>
+    <string>${MACOSX_BUNDLE_BUNDLE_VERSION}</string>
+    <key>CSResourcesFileMapped</key>
+    <true/>
+    <key>LSRequiresCarbon</key>
+    <true/>
+    <key>NSHumanReadableCopyright</key>
+    <string>${MACOSX_BUNDLE_COPYRIGHT}</string>
+    <key>NSPrincipalClass</key>
+    <string>NSApplication</string>
+</dict>
+</plist>
diff --git a/cmake/QtCommon.cmake b/cmake/QtCommon.cmake
new file mode 100644
index 00000000..2145019e
--- /dev/null
+++ b/cmake/QtCommon.cmake
@@ -0,0 +1,76 @@
+macro(fix_project_version)
+if (NOT PROJECT_VERSION_PATCH)
+    set(PROJECT_VERSION_PATCH 0)
+endif()
+
+if (NOT PROJECT_VERSION_TWEAK)
+    set(PROJECT_VERSION_TWEAK 0)
+endif()
+endmacro()
+
+macro(add_project_meta FILES_TO_INCLUDE)
+if (NOT RESOURCE_FOLDER)
+    set(RESOURCE_FOLDER resources)
+endif()
+
+if (NOT ICON_NAME)
+    set(ICON_NAME nheko)
+endif()
+
+if (APPLE)
+    set(ICON_FILE ${RESOURCE_FOLDER}/${ICON_NAME}.icns)
+elseif (WIN32)
+    set(ICON_FILE ${RESOURCE_FOLDER}/${ICON_NAME}.ico)
+endif()
+
+if (WIN32)
+    configure_file("${PROJECT_SOURCE_DIR}/cmake/windows_metafile.rc.in"
+      "windows_metafile.rc"
+    )
+    set(RES_FILES "windows_metafile.rc")
+    set(CMAKE_RC_COMPILER_INIT windres)
+    ENABLE_LANGUAGE(RC)
+    SET(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
+endif()
+
+if (APPLE)
+    set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
+
+    # Identify MacOS bundle
+    set(MACOSX_BUNDLE_BUNDLE_NAME ${PROJECT_NAME})
+    set(MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION})
+    set(MACOSX_BUNDLE_LONG_VERSION_STRING ${PROJECT_VERSION})
+    set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
+    set(MACOSX_BUNDLE_COPYRIGHT ${COPYRIGHT})
+    set(MACOSX_BUNDLE_GUI_IDENTIFIER ${IDENTIFIER})
+    set(MACOSX_BUNDLE_ICON_FILE ${ICON_NAME})
+endif()
+
+if (APPLE)
+    set(${FILES_TO_INCLUDE} ${ICON_FILE})
+elseif (WIN32)
+    set(${FILES_TO_INCLUDE} ${RES_FILES})
+endif()
+endmacro()
+
+macro(init_os_bundle)
+if (APPLE)
+    set(OS_BUNDLE MACOSX_BUNDLE)
+elseif (WIN32)
+    IF(CMAKE_BUILD_TYPE MATCHES Release)
+        set(OS_BUNDLE WIN32)
+    endif()
+endif()
+endmacro()
+
+macro(fix_win_compiler)
+if (MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES
+        WIN32_EXECUTABLE YES
+        LINK_FLAGS "/ENTRY:mainCRTStartup"
+    )
+endif()
+endmacro()
+
+init_os_bundle()
+fix_win_compiler()
diff --git a/cmake/windows_metafile.rc.in b/cmake/windows_metafile.rc.in
new file mode 100644
index 00000000..02008697
--- /dev/null
+++ b/cmake/windows_metafile.rc.in
@@ -0,0 +1,28 @@
+#include "winver.h"
+
+IDI_ICON1               ICON    DISCARDABLE     "@ICON_FILE@"
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
+ PRODUCTVERSION @PROJECT_VERSION_MAJOR@,@PROJECT_VERSION_MINOR@,@PROJECT_VERSION_PATCH@,@PROJECT_VERSION_TWEAK@
+ FILEFLAGS 0x0L
+ FILEFLAGSMASK 0x3fL
+ FILEOS 0x00040004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "000004b0"
+        BEGIN
+            VALUE "CompanyName", "@COMPANY@"
+            VALUE "FileDescription", "@PROJECT_NAME@"
+            VALUE "FileVersion", "@PROJECT_VERSION@"
+            VALUE "LegalCopyright", "@COPYRIGHT@"
+            VALUE "InternalName", "@PROJECT_NAME@"
+            VALUE "OriginalFilename", "@PROJECT_NAME@.exe"
+            VALUE "ProductName", "@PROJECT_NAME@"
+            VALUE "ProductVersion", "@PROJECT_VERSION@"
+        END
+    END
+END