Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build windows libs as static #538

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/compare.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import sys

expected = open('.github/expected_file_list','rt')
expect_list_file = sys.argv[1]
expected = open(expect_list_file,'rt')

expected_files = set()
for line in expected:
Expand Down
33 changes: 33 additions & 0 deletions .github/expected_file_list_static
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
$pluginsdir\installoptions.dll
$pluginsdir\iospecial.ini
$pluginsdir\modern-header.bmp
$pluginsdir\modern-wizard.bmp
$pluginsdir\nsis.installoptions.ini
$pluginsdir\startmenu.dll
$pluginsdir\system.dll
$pluginsdir\userinfo.dll
advapi32.dll
database.dll
face_recognition_models\dlib_face_recognition_resnet_model_v1.dat
face_recognition_models\mmod_human_face_detector.dat
face_recognition_models\shape_predictor_5_face_landmarks.dat
face_recognition_models\shape_predictor_68_face_landmarks.dat
icons\svg\photo_broom.svg
kernel32.dll
libblas.dll
libgcc_s_seh-1.dll
libgfortran-5.dll
liblapack.dll
libquadmath-0.dll
libwinpthread-1.dll
msvcrt.dll
photo_broom.exe
plugins\database\database_sqlite_backend.dll
shell32.dll
sql_backend_base.dll
tools\exiftool\exiftool.exe
tools\hugin\align_image_stack.exe
tr\photo_broom_en.qm
tr\photo_broom_pl.qm
uninstall.exe
ws2_32.dll
8 changes: 4 additions & 4 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
windows_compile_environment: msvc #
windows_compile_environment: msvc

- name: Run vcpkg
uses: lukka/[email protected]
Expand All @@ -60,10 +60,10 @@ jobs:
- name: Build
run: |
cmake --preset "ninja_release_vcpkg" -DBUILD_SHARED_LIBS=TRUE -DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH="${{ env.ccache_symlinks_path }}" -DCMAKE_C_COMPILER_LAUNCHER:FILEPATH="${{ env.ccache_symlinks_path }}"
cmake --build --preset "Ninja Release"
cmake --build --preset "ninja_release"

- name: Make package
run: cmake --build --target package --preset 'Ninja Release'
run: cmake --build --target package --preset 'ninja_release'

- name: Upload artifact
uses: actions/upload-artifact@v3
Expand All @@ -73,4 +73,4 @@ jobs:

- name: Verify list of files in installer
run: |
7z l out/build/ninja_release_vcpkg/PhotoBroom-*-win64.exe | python .github/parse7z-l.py | python .github/compare.py
7z l out/build/ninja_release_vcpkg/PhotoBroom-*-win64.exe | python .github/parse7z-l.py | python .github/compare.py .github/expected_file_list
66 changes: 66 additions & 0 deletions .github/workflows/windows-static-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

name: Build-Static-Windows

on:
push:
branches:
- master
pull_request:

jobs:
build:
runs-on: windows-2022
strategy:
fail-fast: false

steps:
- uses: actions/checkout@v3
with:
submodules: true

- name: Prepare build dir
run: |
New-Item -ItemType directory -Path "c:\" -Name "build"
New-Item -ItemType Junction -Path "out" -Target "c:\build"
Move-Item -Path vcpkg -Destination c:\build
New-Item -ItemType Junction -Path "vcpkg" -Target "c:\build\vcpkg"

- name: Cache external tools
uses: actions/cache@v2
with:
path: out/build/ninja_release_vcpkg/tools
key: ${{ runner.os }}-externalTools-v1-${{ hashFiles('cmake/system/win32.cmake') }}

- name: disable debug build for vcpkg
run: echo 'set(VCPKG_BUILD_TYPE "release")' >> vcpkg/triplets/x64-windows-static.cmake

- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
windows_compile_environment: msvc

- name: Run vcpkg
uses: lukka/[email protected]
with:
vcpkgJsonGlob: vcpkg.json

- name: Add msbuild to PATH
uses: ilammy/[email protected]

- name: Build
run: |
cmake --preset "ninja_release_vcpkg_static" -DBUILD_SHARED_LIBS=TRUE -DCMAKE_CXX_COMPILER_LAUNCHER:FILEPATH="${{ env.ccache_symlinks_path }}" -DCMAKE_C_COMPILER_LAUNCHER:FILEPATH="${{ env.ccache_symlinks_path }}" -DVCPKG_TARGET_TRIPLET=x64-windows-static -DVCPKG_HOST_TRIPLET=x64-windows-static -DBUILD_SHARED_LIBS=FALSE -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
cmake --build --preset "ninja_static_release"

- name: Make package
run: cmake --build --target package --preset 'ninja_static_release'

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: Installer
path: out/build/ninja_release_vcpkg/PhotoBroom-*-win64.exe

- name: Verify list of files in installer
run: |
7z l out/build/ninja_release_vcpkg/PhotoBroom-*-win64.exe | python .github/parse7z-l.py | python .github/compare.py .github/expected_file_list_static
61 changes: 49 additions & 12 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,83 @@
"patch": 0
},
"configurePresets": [
{
"name": "ninja_base",
"hidden": true,
"generator": "Ninja",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}"
},
{
"name": "vcpkg_base",
"hidden": true,
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake"
},
{
"name": "ninja_debug_vcpkg",
"inherits": [ "ninja_base", "vcpkg_base" ],
"displayName": "Ninja Debug Config",
"description": "Configure with vcpkg toolchain",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"generator": "Ninja",
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"description": "Configure with vcpkg toolchain",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "ninja_release_vcpkg",
"inherits": [ "ninja_base", "vcpkg_base" ],
"displayName": "Ninja Release Config",
"description": "Configure with vcpkg toolchain",
"binaryDir": "${sourceDir}/out/build/${presetName}",
"installDir": "${sourceDir}/out/install/${presetName}",
"generator": "Ninja",
"toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": {
"BUILD_TESTING": "OFF",
"CMAKE_BUILD_TYPE": "Release"
"CMAKE_BUILD_TYPE": "Release"
}
},
{
"name": "ninja_debug_vcpkg_static",
"inherits": "ninja_debug_vcpkg",
"displayName": "Ninja Debug Config Static",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static"
}
},
{
"name": "ninja_release_vcpkg_static",
"inherits": "ninja_release_vcpkg",
"displayName": "Ninja Release Config Static",
"cacheVariables": {
"VCPKG_TARGET_TRIPLET": "x64-windows-static",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded"
}
}
],
"buildPresets": [
{
"name": "Ninja Debug",
"name": "ninja_debug",
"configurePreset": "ninja_debug_vcpkg",
"displayName": "Build Debug",
"description": "Build Debug with Ninja",
"configuration": "Debug"
},
{
"name": "Ninja Release",
"name": "ninja_release",
"configurePreset": "ninja_release_vcpkg",
"displayName": "Build Release",
"description": "Build Release with Ninja",
"configuration": "Release"
},
{
"name": "ninja_static_debug",
"configurePreset": "ninja_debug_vcpkg_static",
"displayName": "Build Static Debug",
"description": "Build Static Debug with Ninja",
"configuration": "Debug"
},
{
"name": "ninja_static_release",
"configurePreset": "ninja_release_vcpkg_static",
"displayName": "Build Static Release",
"description": "Build Static Release with Ninja",
"configuration": "Release"
}
]
}
3 changes: 1 addition & 2 deletions cmake/system/win32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ function(download_tools)

if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin-2021.0.0-win64.msi)
message("Downloading Hugin")
find_program(APP_7Z 7z REQUIRED)
file(DOWNLOAD
https://netix.dl.sourceforge.net/project/hugin/hugin/hugin-2021.0/Hugin-2021.0.0-win64.msi ${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin-2021.0.0-win64.msi
SHOW_PROGRESS
)

find_program(APP_7Z 7z REQUIRED)
execute_process(
COMMAND
${APP_7Z} e
Expand Down