Mateusz Loskot :: hacking on, working out, living up

Building GEOS with CMake and Visual Studio 2019 on Windows

24 May 2019 | mloskot

Finally, my proposal of modernised CMake configuration GEOS PR #130 has been accepted to GEOS codebase. Together with Paul Ramsey, Dan Baston and Martin Davis, we picked it up and spent some time during the OSGeo Code Sprint 2019 last week, preparing it for final integration.

The new CMake requires fairly recent, two or three years old but not older, version of CMake (3.83.9 or later). In order to build GEOS with the latest release of VS 2019, we need CMake 3.14.

CMake user rule #1: Use the very latest version of CMake


Learn about CMake drivers

Clone GEOS

git clone
cd geos

Build with CMake generator for Ninja (fast)

In the Visual Studio 2019 command prompt, x64 Native Tools Command Prompt for VS 2019 or x64_x86 Cross Tools Command Prompt for VS 2019:

cmake -S . -B _build_vs2019_ninja -G Ninja -DCMAKE_BUILD_TYPE=Release
cmake --build _build_vs2019_ninja -j 16 --verbose

Build with CMake generator for MSBuild (default)

In the non-specific Command Prompt:


cmake -S . -B _build_vs2019x64 -G "Visual Studio 16 2019" -A x64 -DCMAKE_GENERATOR_TOOLSET=host=x64
cmake --build _build_vs2019x64 --config Release -j 16 --verbose


cmake -S . -B _build_vs2019x32 -G "Visual Studio 16 2019" -A win32 -DCMAKE_GENERATOR_TOOLSET=host=x64
cmake --build _build_vs2019x32 --config Release -j 16 --verbose

Bonus: IncrediBuild

Using IncrediBuild BuildCosole.exe driver:

cd _build_vs2019x64
"%ProgramFiles(x86)%\IncrediBuild\BuildConsole.exe" GEOS.sln /build /cfg="Release|x64" /vsversion=vc16
cd _build_vs2019x32
"%ProgramFiles(x86)%\IncrediBuild\BuildConsole.exe" GEOS.sln /build /cfg="Release|Win32" /vsversion=vc16


cd <build directory>
ctest --show-only
ctest --build-config Release
ctest --build-config Release --output-on-failure
ctest --build-config Release -V
ctest --build-config Release -VV

Build times

Brief comparison of build times for handful of build generators and build strategies on machine with 24 physical cores:

Call for testing

I created a very extensive CI build matrix with Azure Pipelines and set it up for my fork of GitHub’s libgeos/geos. The builds can be observed at If GEOS accepts my PR #170, then every contributor will be able to set up the CI pipeline for her own fork.

The new CMake configuration for GEOS still needs testing and reviews, especially from seasoned modern and effective CMake users. Have a go and report issues.

Fork me on GitHub