Build multiple CMake configurations
Hi,
I am using AppVeyor to build a C++ library that uses CMake as build system. The library can be built as both static and dynamic library and this can be configured by passing either -DBUILD_SHARED_LIBS=0 or -DBUILD_SHARED_LIBS=1 as command line argument to cmake. How can I configure AppVeyor (using appveyor.yml) so that it builds both versions? The current appveyor.yml looks like this:
version: 1.0.{build}
image:
- Visual Studio 2019
- Visual Studio 2017
configuration:
- Debug
- Release
before_build:
- cmd: cmake -H. -B./build -DBUILD_SHARED_LIBS=1
build:
verbosity: normal
I tried wrapping the before_build in a for, but this did not work (AppVeyor ran once with -DBUILD_SHARED_LIBS=1 but skipped the ...=0 version):
for:
-
before_build:
- cmd: cmake -H. -B./build -DBUILD_SHARED_LIBS=1
-
before_build:
- cmd: cmake -H. -B./build -DBUILD_SHARED_LIBS=0
I also tried adding a matrix to the before_build, but this did not work either (AppVeyor showed Error parsing appveyor.yml: Script contents must be a string (Line: 10, Column: 3)):
before_build:
matrix:
- cmd: cmake -H. -B./build -DBUILD_SHARED_LIBS=1
- cmd: cmake -H. -B./build -DBUILD_SHARED_LIBS=0
How can I configure AppVeyor so that it builds both versions?
Regards,
Philip
Keyboard shortcuts
Generic
| ? | Show this help |
|---|---|
| ESC | Blurs the current field |
Comment Form
| r | Focus the comment reply box |
|---|---|
| ^ + ↩ | Submit the comment |
You can use Command ⌘ instead of Control ^ on Mac

Support Staff 1 Posted by Feodor Fitsner on 05 Nov, 2019 05:28 PM
Hi Philip,
This is probably the config you are looking for:
2 Posted by Philip on 05 Nov, 2019 07:57 PM
That works great, thank you! I did not know that you can use environment variables for this.