Skip to content
Snippets Groups Projects
Commit 530cc397 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

Update build instructions on Windows to use make.ps1

parent 567c8eef
No related branches found
No related tags found
2 merge requests!61Release 0.3.0,!54Resolve "Windows: Linker errors with protobuf-generated code"
...@@ -108,22 +108,19 @@ How to build on Windows ...@@ -108,22 +108,19 @@ How to build on Windows
We use `Visual Studio We use `Visual Studio
2022 <https://visualstudio.microsoft.com/de/vs/features/cplusplus/>`__ 2022 <https://visualstudio.microsoft.com/de/vs/features/cplusplus/>`__
as compiler. We use `cmake <https://cmake.org/download/>`__ as build as compiler. We use `cmake <https://cmake.org/download/>`__ as build
tool. tool, which can be installed together with Visual Studio.
1. Install Python and create a virtual environment with the dependencies in `requirements.txt`. 1. Install Python and create a virtual environment with the dependencies in
2. Activate the environment run in the repository folder: ``conan install . --build=missing -s build_type=Release`` `requirements.txt`.
3. ``cmake --preset conan-default`` 2. In a PowerShell, activate the environment and run the following commands from the
4. Open ``build/liblinkahead.sln`` with Visual Studio, change the repository root:
buildtype to ``Release`` and build the project (ALL_BUILD). (You 3. ``conan profile detect --force`` (and check the output)
can open Tools/Command Line/Developer Command Prompt and execute 3. ``make.ps1 conan-install``
``msbuild liblinkahead.sln /property:Configuration=Release``) 4. ``make.ps1 build``
5. Try running the cli clients in ``.\build\Release\``.
You'll find the shared libraries and cli clients in ``.\build\Release\``. To run the tests,
Known problems use ``make.ps1 test``. As a shortcut to run all steps, use ``make.ps1 all``.
^^^^^^^^^^^^^^
- Building the unit tests on Windows currently fails with linker errors. See
`#90 <https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib/-/issues/90>`__
Troubleshooting Troubleshooting
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~
......
...@@ -2,28 +2,22 @@ param ( ...@@ -2,28 +2,22 @@ param (
[string]$target [string]$target
) )
# check if vswhere is available function Install-Conan {
if (-not (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe")) { Write-Output "Installing Release dependencies with Conan..."
Write-Output "vswhere is not available. Please install Visual Studio" # check if conan is available
if (-not (Get-Command conan -ErrorAction SilentlyContinue)) {
Write-Output "Conan is not available. Please install Conan or activate the Conan environment venv"
exit 1 exit 1
} }
conan install . --build=missing -s build_type=Release -s compiler.cppstd=17
cmake --preset conan-default
}
# locate the latest Visual Studio installation function Build-Project {
$currentPath = Get-Location
$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $installPath
Set-Location $currentPath
# Windows is with Release only for now
switch ($target) {
"build" {
Write-Output "Building the project..." Write-Output "Building the project..."
# check if msbuild is available # check if msbuild is available
if (-not (Get-Command msbuild -ErrorAction SilentlyContinue)) { if (-not (Get-Command msbuild -ErrorAction SilentlyContinue)) {
Write-Output "msbuild is not available. Please install Visual Studio or open the Developer PowerShell:." Write-Output "msbuild is not available. Please install Visual Studio or open the Developer PowerShell."
exit 1 exit 1
} }
# check if conan install was run # check if conan install was run
...@@ -33,7 +27,8 @@ switch ($target) { ...@@ -33,7 +27,8 @@ switch ($target) {
} }
msbuild .\build\liblinkahead.sln /property:Configuration=Release msbuild .\build\liblinkahead.sln /property:Configuration=Release
} }
"test" {
function Invoke-Tests {
Write-Output "Running tests..." Write-Output "Running tests..."
# check if build was run before # check if build was run before
if (-not (Test-Path .\build\Release\linkahead.dll)) { if (-not (Test-Path .\build\Release\linkahead.dll)) {
...@@ -42,24 +37,44 @@ switch ($target) { ...@@ -42,24 +37,44 @@ switch ($target) {
} }
Set-Location .\build\ Set-Location .\build\
ctest ctest
} }
"conan-install" {
Write-Output "Installing Release dependencies with Conan..." # check if vswhere is available
# check if conan is available if (-not (Test-Path "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe")) {
if (-not (Get-Command conan -ErrorAction SilentlyContinue)) { Write-Output "vswhere is not available. Please install Visual Studio"
Write-Output "Conan is not available. Please install Conan or activate the Conan environment venv"
exit 1 exit 1
} }
conan install . --build=missing -s build_type=Release -s compiler.cppstd=17
cmake --preset conan-default # locate the latest Visual Studio installation
$currentPath = Get-Location
$installPath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -property installationPath
Import-Module (Join-Path $installPath "Common7\Tools\Microsoft.VisualStudio.DevShell.dll")
Enter-VsDevShell -VsInstallPath $installPath
Set-Location $currentPath
# Windows is with Release only for now
switch ($target) {
"build" {
Build-Project
}
"test" {
Invoke-Tests
}
"conan-install" {
Install-Conan
} }
"clean"{ "clean"{
Write-Output "Cleaning the project..." Write-Output "Cleaning the project..."
Remove-Item -Recurse -Force .\build\* Remove-Item -Recurse -Force .\build\*
} }
"all" {
Install-Conan
Build-Project
Invoke-Tests
}
default { default {
Write-Output "Usage: .\script.ps1 [conan-install|build|test|clean]" Write-Output "Usage: .\make.ps1 [all|conan-install|build|test|clean]"
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment