Skip to content
Merged
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
17 changes: 6 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ jobs:
- name: Install dependencies
run: |
brew update
brew install --formula flatbuffers swig doxygen boost
brew install --formula swig doxygen
- name: Cache vcpkg
if: matrix.target != 'macos'
uses: actions/cache@v5
with:
path: ${{ github.workspace }}/vcpkg_cache
Expand Down Expand Up @@ -129,6 +128,7 @@ jobs:
env:
CXXFLAGS: '/D_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR' # https://github.com/actions/runner-images/issues/10004
DEST: ${{ github.workspace }}/${{ matrix.image }}_${{ matrix.platform }}
VCPKG_ROOT: C:/vcpkg
steps:
- name: Checkout
uses: actions/checkout@v6
Expand All @@ -148,15 +148,10 @@ jobs:
VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}/vcpkg_cache,readwrite
run: |
$swig = (Get-Item "$env:LOCALAPPDATA\Microsoft\WinGet\Links\swig.exe").Target
cmake -A ${{ matrix.platform }} -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo `
"-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake" `
"-DSWIG_EXECUTABLE=$swig" `
-DVCPKG_TARGET_TRIPLET=${{ matrix.platform }}-windows-static-md `
${{ matrix.platform == 'x64' && '-DVCPKG_MANIFEST_FEATURES=tests' || '' }} `
-DCMAKE_INSTALL_LIBDIR=bin
cmake --build build --config RelWithDebInfo
ctest -V -C RelWithDebInfo --test-dir build
cmake --install build --config RelWithDebInfo --prefix ${{ env.DEST }}
$vsPath = & "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationPath
& "$vsPath\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.platform == 'arm64' && 'amd64_arm64' || 'amd64' }} "&&" pwsh build.ps1 `
-swig $swig -installdir ${{ env.DEST }} -buildType RelWithDebInfo `
${{ matrix.platform == 'x64' && '-RunTests' || '' }}
- name: Archive artifacts
uses: actions/upload-artifact@v7
with:
Expand Down
25 changes: 21 additions & 4 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
"displayName": "Ninja",
"description": "Sets Ninja generator, build and install directory",
"generator": "Ninja",
"binaryDir": "${sourceDir}/build",
"binaryDir": "${sourceDir}/build/${presetName}",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"CMAKE_INSTALL_PREFIX": "${sourceDir}/out/install/${presetName}",
"CMAKE_C_COMPILER": "cl.exe",
"CMAKE_CXX_COMPILER": "cl.exe",
"VCPKG_MANIFEST_FEATURES": "tests"
}
},
Expand All @@ -27,9 +25,12 @@
"rhs": "Darwin"
},
"cacheVariables": {
"CMAKE_OSX_ARCHITECTURES": "arm64",
"CMAKE_OSX_ARCHITECTURES": "arm64;x86_64",
"CMAKE_OSX_DEPLOYMENT_TARGET": "14.0",
"CMAKE_FIND_ROOT_PATH": "$env{DEST};/opt/homebrew",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "arm64-x64-osx",
"VCPKG_MANIFEST_FEATURES": "tests",
"FRAMEWORK_DESTINATION": "$env{DEST}/lib"
},
"installDir": "$env{DEST}"
Expand All @@ -54,6 +55,7 @@
"inherits": ["mobile", "macos"],
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "iOS",
"CMAKE_OSX_ARCHITECTURES": "arm64",
"CMAKE_OSX_SYSROOT": "${presetName}",
"CMAKE_OSX_DEPLOYMENT_TARGET": "16.3",
"CMAKE_DISABLE_FIND_PACKAGE_SWIG": "YES"
Expand Down Expand Up @@ -111,6 +113,17 @@
"CMAKE_ANDROID_ARCH_ABI": "x86_64",
"VCPKG_TARGET_TRIPLET": "x64-android"
}
},
{
"name": "windows",
"displayName": "Windows",
"description": "This windows build is only available on Windows",
"binaryDir": "${sourceDir}/build/windows-$env{PLATFORM}",
"cacheVariables": {
"CMAKE_INSTALL_LIBDIR": "bin",
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "$env{PLATFORM}-windows-static-md"
}
}
],
"buildPresets":
Expand Down Expand Up @@ -138,6 +151,10 @@
{
"name": "androidx86_64",
"configurePreset": "androidx86_64"
},
{
"name": "windows",
"configurePreset": "windows"
}
]
}
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,12 @@ For more information refer [doc/intro.md](doc/intro.md) document.
* [Visual Studio Community 2022](https://www.visualstudio.com/downloads/)
* [CMake](http://www.cmake.org)
* [vcpkg](https://vcpkg.io/)
* [Swig](http://swig.org/download.html) - Optional, for C#, Python and Java bindings
* [Swig](http://swig.org/download.html) - Optional, for C# and Java bindings
* [Doxygen](https://www.doxygen.nl/download.html) - Optional, for generating documentation
* [Wix toolset](http://wixtoolset.org/releases/) - Optional, for creating Windows installation packages
* [Python](https://www.python.org/downloads/) - Optional, for Python bindings
* [Java](https://www.oracle.com/java/technologies/downloads/) - Optional, for Java bindings

2. Open desired Visual Studio tools command prompt:
* x64 Native Tool Command Prompt
* x86 Native Tool Command Prompt
* ARM64 Native Tool Command Prompt
* Or some cross compile combination with target host type

Expand All @@ -108,6 +105,16 @@ For more information refer [doc/intro.md](doc/intro.md) document.
git clone https://github.com/open-eid/libcdoc.git
cd libcdoc

4. Configure and Build
4. Configure, build and install

.\build.ps1

`build.ps1` drives the `windows` CMake preset with vcpkg. If neither the `-vcpkg`
parameter nor the `VCPKG_ROOT` environment variable points to a vcpkg checkout, one is
cloned automatically. By default it builds the x64 Debug and RelWithDebInfo
configurations. Common options:

.\build.ps1 -platform arm64 # target ARM64
.\build.ps1 -RunTests # build and run the unit tests
.\build.ps1 -installdir C:\libcdoc # install after building
.\build.ps1 -generator "Visual Studio 17 2022" # use another CMake generator
50 changes: 22 additions & 28 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,52 +1,46 @@
#powershell -ExecutionPolicy ByPass -File build.ps1
param(
[string]$libcdoc = $PSScriptRoot,
[string]$platform = "x64",
[string]$platform = $(if ($null -eq $env:PLATFORM) {"x64"} else {$env:PLATFORM}),
[string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}),
[string]$git = "git.exe",
[string]$vcpkg = $env:VCPKG_ROOT,
[string]$vcpkg_installed = $null,
[string]$vcpkg_installed_platform = $(if($vcpkg_installed) { "$vcpkg_installed\vcpkg_installed_$platform" } else { "$libdigidocpp\build\windows-$platform\vcpkg_installed" }),
[string]$vcpkg_triplet = "$platform-windows",
[string]$cmake = "cmake.exe",
[string]$generator = "Visual Studio 17 2022",
[switch]$RunTests = $false,
[string]$generator = "Ninja Multi-Config",
[string]$swig = $null,
[string]$installdir = $null,
[string[]]$buildType = @("Debug", "RelWithDebInfo"),
[switch]$RunTests = $false
)

if(!(Test-Path -Path $vcpkg)) {
$vcpkg = "$libdigidocpp\vcpkg"
if(!$vcpkg -or !(Test-Path -Path $vcpkg)) {
$vcpkg = "$libcdoc\vcpkg"
& $git clone https://github.com/microsoft/vcpkg $vcpkg
& $vcpkg\bootstrap-vcpkg.bat
}

$cmakeext = @()
if($platform -eq "arm64" -and $env:VSCMD_ARG_HOST_ARCH -ne "arm64") {
$cmakeext += "-DCMAKE_DISABLE_FIND_PACKAGE_Python3=yes"
$RunTests = $false
if($swig) {
$cmakeext += "-DSWIG_EXECUTABLE=$swig"
}
if($RunTests) {
$cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests"
}
if($installdir) {
$cmakeext += "-DCMAKE_INSTALL_PREFIX=$installdir"
}

$buildpath = "build"
$env:PLATFORM = $platform
$env:VCPKG_ROOT = $vcpkg

& $cmake --fresh -B $buildpath -S . "-G$generator" $cmakeext `
"--toolchain $vcpkg/scripts/buildsystems/vcpkg.cmake" `
"-DVCPKG_INSTALLED_DIR=$vcpkg_installed_platform" `
"-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet"

foreach($type in @("Debug", "RelWithDebInfo")) {
"==================="
"Build Configuration: " + $type
"==================="
& $cmake --build $buildpath --config $type
# & $cmake --install $buildpath
}
& $cmake --preset windows --fresh "-G$generator" $cmakeext

if($RunTests) {
Push-Location "$libcdoc\$buildpath"
ctest -V -C Debug
Pop-Location
foreach($type in $buildType) {
& $cmake --build --preset windows --config $type
if($RunTests) {
& $cmake --build --preset windows --config $type --target check
}
if($installdir) {
& $cmake --build --preset windows --config $type --target install
}
}
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ if(WIN32)
)
endif()

add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS unittests)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG> --output-on-failure DEPENDS unittests)
7 changes: 7 additions & 0 deletions vcpkg-triplets/arm64-x64-osx.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
set(VCPKG_TARGET_ARCHITECTURE arm64 x86_64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE static)

set(VCPKG_CMAKE_SYSTEM_NAME Darwin)
set(VCPKG_OSX_ARCHITECTURES arm64 x86_64)
set(VCPKG_OSX_DEPLOYMENT_TARGET 14.0)
15 changes: 6 additions & 9 deletions vcpkg.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,14 @@
"default-features": false,
"platform": "!osx"
},
{
"name": "flatbuffers",
"platform": "!osx"
},
{
"name": "openssl",
"platform": "!osx"
}
"flatbuffers",
"openssl"
],
"features": {
"tests": { "description": "Build tests", "dependencies": ["boost-test"] }
"tests": {
"description": "Build tests",
"dependencies": [{ "name": "boost-test", "platform": "!ios & !android" }]
}
},
"builtin-baseline": "67b5ee32c608c87971eed243d4bff140568ebe53",
"vcpkg-configuration": {
Expand Down
Loading