Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save natthasath/5bcd4796d68f2fd44ece524b48f655ae to your computer and use it in GitHub Desktop.
Save natthasath/5bcd4796d68f2fd44ece524b48f655ae to your computer and use it in GitHub Desktop.
build-geos-with-cmake-vs2019.md : Building GEOS with CMake and Visual Studio on Windows

Building GEOS with CMake and Visual Studio 2019 on Windows

Learn about CMake drivers

Clone GEOS

git clone https://github.com/libgeos/geos.git
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:

64-bit

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

32-bit

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

Test

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

On machine with 24 physical cores:

  • Ninja with -j 16

    Start: 15:04:07
    End:   15:04:42
    
  • MSBuild with -maxcpucount:16 (value not very relevant though)

    Start: 14:43:49
    End:   14:50:04
    
  • IncrediBuild with 16 cores package

    Start: 14:31:49
    End:   14:34:03
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment