From 6695a3f92384c6b6dd2c02faecb7d3eaba71a675 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 24 Feb 2024 22:38:26 +0300 Subject: [PATCH 1/4] [windows] add option to build non-admin executable --- CMakeLists.txt | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43acc90..fb7d96a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,7 @@ endif() # options if(WIN32) option(DUMMY_WRITE "Write image to local file named 'dummy_image_file' instead to real device (for testing)") + option(REQUIRE_ADMIN "Build exe that runs only as administrator" ON) endif() # dependencies @@ -125,19 +126,23 @@ qt_add_translations(LibreELEC.USB-SD.Creator ) if(WIN32) - if(MSVC) - set_target_properties(LibreELEC.USB-SD.Creator PROPERTIES - LINK_OPTIONS "/MANIFEST:NO" # disable default manifest - ) - endif() - target_sources(LibreELEC.USB-SD.Creator PUBLIC deviceenumerator_windows.cpp deviceenumerator_windows.h diskwriter_windows.cpp diskwriter_windows.h privileges.h - windows/winapp.rc ) + if(REQUIRE_ADMIN) + target_sources(LibreELEC.USB-SD.Creator PUBLIC + windows/winapp.rc + ) + if(MSVC) + set_target_properties(LibreELEC.USB-SD.Creator PROPERTIES + LINK_OPTIONS "/MANIFEST:NO" # disable default manifest + ) + endif() + endif() + configure_file("windows/winapp.rc.in" "${CMAKE_SOURCE_DIR}/windows/winapp.rc" @ONLY) set(qtDeployExecutable "$") From bb3ef1e6e51055a7ad6fb28c710b22430224715a Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 24 Feb 2024 22:39:58 +0300 Subject: [PATCH 2/4] produce cpack package in a subdirectory --- .github/workflows/build.yaml | 13 ++++++++----- CMakeLists.txt | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2747eb8..2121d24 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -13,11 +13,11 @@ jobs: - os: macos-latest platform: macos preset: release-macos - artifact: '*.dmg' + cpack: true - os: windows-latest platform: windows-msvc preset: release-msvc - artifact: '*.Win32.exe' + cpack: true useQtAction: true - os: windows-latest platform: windows-mingw @@ -34,6 +34,7 @@ jobs: MACOS_ASC_API_KEY: ${{ secrets.MACOS_ASC_API_KEY }} MACOS_CODE_SIGN_KEY_BASE64: ${{ secrets.MACOS_CODE_SIGN_KEY_BASE64 }} MACOS_KEYCHAIN_PASSWORD: ${{ secrets.MACOS_KEYCHAIN_PASSWORD }} + - name: Install Qt uses: jurplel/install-qt-action@v3 if: ${{ matrix.useQtAction }} @@ -50,6 +51,7 @@ jobs: with: arch: x64 toolset: 14.29 + - name: Setup msys2 uses: msys2/setup-msys2@v2 if: ${{ matrix.platform == 'windows-mingw' }} @@ -65,14 +67,16 @@ jobs: if: ${{ matrix.platform == 'windows-mingw' }} run: | echo "${{ runner.temp }}/msys64/mingw64/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - name: Configure run: | cmake --preset ${{ matrix.preset || 'release' }} - name: Build run: | cmake --build --preset release + - name: Pack - if: ${{ matrix.artifact }} + if: ${{ matrix.cpack }} run: | cpack --preset release env: @@ -80,9 +84,8 @@ jobs: ASC_API_KEY_ISSUER: ${{ secrets.MACOS_ASC_API_KEY_ISSUER }} ASC_TEAM_ID: ${{ secrets.MACOS_ASC_TEAM_ID }} - name: Artifact - if: ${{ matrix.artifact }} uses: actions/upload-artifact@v4 with: - path: build/${{ matrix.artifact }} + path: build/cpack/LibreELEC.USB-SD.Creator.* name: ${{ matrix.platform }} compression-level: 0 diff --git a/CMakeLists.txt b/CMakeLists.txt index fb7d96a..b1e8999 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,6 +220,7 @@ if(qtDeployExecutable) endif() # cpack +set(CPACK_PACKAGE_DIRECTORY "cpack") set(CPACK_PACKAGE_NAME "${projectDisplayName}") set(CPACK_PACKAGE_VENDOR "LibreELEC") if(WIN32) From eab45e6d63e7b75e44fb5f7c3269beea957e444b Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 24 Feb 2024 22:40:53 +0300 Subject: [PATCH 3/4] [CI] also produce zip for MSVC build --- .github/workflows/build.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2121d24..7c4a8af 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -83,6 +83,10 @@ jobs: ASC_API_KEY_ID: ${{ secrets.MACOS_ASC_API_KEY_ID }} ASC_API_KEY_ISSUER: ${{ secrets.MACOS_ASC_API_KEY_ISSUER }} ASC_TEAM_ID: ${{ secrets.MACOS_ASC_TEAM_ID }} + - name: Pack zip + if: ${{ matrix.platform == 'windows-msvc' }} + run: | + cpack --preset release -G ZIP - name: Artifact uses: actions/upload-artifact@v4 with: From 14f5e36ae0102b85bf6e9ced3750db68be270cff Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Sat, 24 Feb 2024 22:41:12 +0300 Subject: [PATCH 4/4] [windows] rename installer --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1e8999..2e34d37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -224,7 +224,7 @@ set(CPACK_PACKAGE_DIRECTORY "cpack") set(CPACK_PACKAGE_NAME "${projectDisplayName}") set(CPACK_PACKAGE_VENDOR "LibreELEC") if(WIN32) - set(CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.Win32") + set(CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.x64") set(CPACK_GENERATOR INNOSETUP) elseif(APPLE) set(CPACK_PACKAGE_FILE_NAME "LibreELEC.USB-SD.Creator.macOS")