Skip to content

Commit

Permalink
Merge pull request #44 from stefanb2/topic-generate-nsis-package
Browse files Browse the repository at this point in the history
Generate Windows installer package
  • Loading branch information
bkueng authored Nov 16, 2023
2 parents 689a390 + fcb5181 commit 3c0dfa5
Show file tree
Hide file tree
Showing 11 changed files with 328 additions and 329 deletions.
37 changes: 10 additions & 27 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,41 +110,23 @@ jobs:
- name: Configure
run: |
rm -rf ${RUNNER_TEMP}/build
cmake -GNinja -B ${RUNNER_TEMP}/build .
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -B ${RUNNER_TEMP}/build .
- name: Build
run: cmake --build ${RUNNER_TEMP}/build

- name: Install
env:
LINUXDEPLOY_DIR: ${{ runner.temp }}/linuxdeploy
run: |
rm -rf ${RUNNER_TEMP}/install
cmake --install ${RUNNER_TEMP}/build --prefix ${RUNNER_TEMP}/install
cp -pr ${RUNNER_TEMP}/build/translations ${RUNNER_TEMP}/install/
rm -rf ${LINUXDEPLOY_DIR}
cmake --install ${RUNNER_TEMP}/build --prefix ${LINUXDEPLOY_DIR}/AppDir/usr
- name: Test
run: |
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -B ${RUNNER_TEMP}/build .
cmake --build ${RUNNER_TEMP}/build --target test
- name: Prepare AppImage Build
env:
LINUXDEPLOY_DIR: ${{ runner.temp }}/linuxdeploy
run: |
mkdir -p \
${LINUXDEPLOY_DIR}/AppDir/usr/share/metainfo \
${LINUXDEPLOY_DIR}/AppDir/usr/share/qMasterPassword \
${LINUXDEPLOY_DIR}/AppDir/usr/translations
cp -p data/qMasterPassword.appdata.xml ${LINUXDEPLOY_DIR}/AppDir/usr/share/metainfo/
cp -p ${RUNNER_TEMP}/install/bin/qMasterPassword ${LINUXDEPLOY_DIR}/
cp -pr \
${RUNNER_TEMP}/install/translations \
${LINUXDEPLOY_DIR}/AppDir/usr/share/qMasterPassword/
if: |
matrix.appimage
- name: Download linuxdeploy
working-directory: ${{ runner.temp }}/linuxdeploy
run: >
Expand All @@ -162,15 +144,16 @@ jobs:
APPIMAGE_EXTRACT_AND_RUN: 1
QML_SOURCES_PATHS: ${{ github.workspace }}/src
run: >
mkdir -p AppDir/usr/translations &&
chmod +x ./*.AppImage &&
./linuxdeploy-x86_64.AppImage
--verbosity=2
--appdir=AppDir
--desktop-file=${GITHUB_WORKSPACE}/data/qMasterPassword.desktop
--executable=qMasterPassword
--icon-file=${GITHUB_WORKSPACE}/data/icons/app_icon.png
--icon-filename=qmasterpassword
--desktop-file=AppDir/usr/share/applications/qMasterPassword.desktop
--executable=AppDir/usr/bin/qMasterPassword
--icon-file=AppDir/usr/share/pixmaps/qmasterpassword.png
--plugin=qt
--output=appimage &&
Expand Down
32 changes: 31 additions & 1 deletion .github/workflows/build-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:

- name: Add msbuild to PATH
uses: microsoft/[email protected]
with:
msbuild-architecture: x64

- name: Install Qt
uses: jurplel/install-qt-action@v3
Expand All @@ -33,9 +35,37 @@ jobs:
setup-python: false

- name: Configure
env:
WINDEPLOY_DIR: ${{ runner.temp }}/windeploy
NSIS_DIR: ${{ runner.temp }}/nsis
run: |
if (Test-Path ${{ runner.temp }}/build) { remove-item -recurse -force ${{ runner.temp }}/build }
cmake -B ${{ runner.temp }}/build .
- name: Build
run: |
cmake --build ${{ runner.temp }}/build
cmake --build ${{ runner.temp }}/build --config Release
- name: Install
run: |
if (Test-Path ${{ runner.temp }}/windeploy) { remove-item -recurse -force ${{ runner.temp }}/windeploy }
cmake --install ${{ runner.temp }}/build --prefix ${{ runner.temp }}/windeploy
- name: Run windeployqt
run: |
$env:VCINSTALLDIR="$(vswhere -latest -property installationPath)/VC"
cmake --build ${{ runner.temp }}/build --config Release --target windeployqt
- name: Build installer package
run: |
if (Test-Path ${{ runner.temp }}/nsis) { remove-item -recurse -force ${{ runner.temp }}/nsis }
mkdir -path ${{ runner.temp }}/nsis
cmake --build ${{ runner.temp }}/build --config Release --target makensis
- name: Upload installer package
uses: actions/upload-artifact@v3
with:
name: windows-installer
path: ${{ runner.temp }}/nsis/qMasterPassword.exe
if: |
startsWith(matrix.qt, '6')
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
*.a

/build*
/install
/windeploy
/nsis
/.config
/release
/debug
Expand Down Expand Up @@ -35,4 +38,4 @@ ui/ui_*.h

/.qtc_clangd

/cmake-build-*
/cmake-build-*
50 changes: 47 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ set(CMAKE_SKIP_RPATH ON)

find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Gui Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} OPTIONAL_COMPONENTS DBus Test)
if(CMAKE_BUILD_TYPE STREQUAL Debug)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Test)
endif()
find_package(OpenSSL REQUIRED)

# exposes ${TS_FILES}
Expand Down Expand Up @@ -44,7 +46,8 @@ else()
qt_add_executable(${TARGET} WIN32)

qt_add_lrelease(${TARGET}
TS_FILES ${TS_FILES}
TS_FILES ${TS_FILES}
QM_FILES_OUTPUT_VARIABLE QM_FILES
)
endif()

Expand All @@ -53,7 +56,8 @@ add_subdirectory(src)
add_subdirectory(test)
add_subdirectory(ui)

if(LINUX)
# LINUX requires CMake >= 3.25.0
if(LINUX OR (UNIX AND NOT APPLE))
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${TARGET} PRIVATE
-Wno-unused-parameter
Expand All @@ -74,6 +78,8 @@ target_link_libraries(${TARGET} PRIVATE
target_include_directories(${TARGET} PRIVATE ${OPENSSL_INCLUDE_DIR})

if(UNIX)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS DBus)
find_package(X11 REQUIRED COMPONENTS Xtst xkbcommon_X11)
target_link_libraries(${TARGET} PRIVATE
Qt::DBus
X11
Expand All @@ -86,8 +92,46 @@ if(WIN32)
target_link_libraries(${TARGET} PRIVATE
ws2_32
)

# find path to Qt binaries from qmake location
get_target_property(QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
get_filename_component(QT_BIN_DIR "${QMAKE_EXECUTABLE}" DIRECTORY)
add_custom_target(windeployqt
COMMAND ${QT_BIN_DIR}/windeployqt
--release
--translations ${TRANSLATIONS}
--verbose 2
\"$ENV{WINDEPLOY_DIR}/bin/${CMAKE_PROJECT_NAME}$<TARGET_FILE_SUFFIX:${TARGET}>\"
)
endif()

add_custom_target(makensis
COMMAND makensis
-DWINDEPLOY_DIR="$ENV{WINDEPLOY_DIR}"
-DNSIS_DIR="$ENV{NSIS_DIR}"
-v4
-wx
${CMAKE_CURRENT_SOURCE_DIR}/data/windows/installer.nsi
)
install(
TARGETS ${TARGET}
)
install(
FILES ${QM_FILES}
DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/translations
)
if(LINUX OR (UNIX AND NOT APPLE))
install(
FILES data/${CMAKE_PROJECT_NAME}.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications
)
install(
FILES data/${CMAKE_PROJECT_NAME}.appdata.xml
DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo
)
install(
FILES data/icons/app_icon.png
DESTINATION ${CMAKE_INSTALL_DATADIR}/pixmaps
RENAME qmasterpassword.png
)
endif()
4 changes: 4 additions & 0 deletions data/translations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ list(TRANSFORM translation_files

# expose list as ${TS_FILES} to parent scope
set(TS_FILES ${translation_files} PARENT_SCOPE)

# expose comma-separated list of locales to parent scope
string(REPLACE ";" "," translations "${locales}")
set(TRANSLATIONS ${translations} PARENT_SCOPE)
Loading

0 comments on commit 3c0dfa5

Please sign in to comment.