Building WindNinja for FlamMap Farsite on Windows using VCPKG - firelab/windninja GitHub Wiki

Building WindNinja for FlamMap/Farsite on Windows using VCPKG

These are instructions for building WindNinjadll.dll for Windows for use with FlamMap and Farsite families of models in the FireModels repository.

VCPKG is a free C/C++ package manager for acquiring and managing libraries maintained by Microsoft.

NOTE: All work/commands should be issued from the 'x64 Native Tools Command Prompt for VS 2022' installed with Visual Studio 2022

Install and build vcpkg

See Installing vcpkg

In short, you will need to clone the vcpkg repository, and run the bootstrap script. You only need to follow Step 1 and the first part of Step 2

Step 1

git clone https://github.com/microsoft/vcpkg.git

cd vcpkg

.\bootstrap-vcpkg.bat

The above will build vcpkg on your machine for use as a package manager

Step 2

Set the necessary environment variables

You can set the necessary environment variables for a single terminal session or permanently.

Single Session

$env:VCPKG_ROOT = "C:\path\to\vcpkg" $env:PATH = "$env:VCPKG_ROOT;$env:PATH"

Permanently

Open Windows System Environment Variables dialog, and select 'New'. Enter VCPKG_ROOT as the variable name and the complete path to the root of the vcpkg repo on your machine as the variable value.

The PATH variable also needs to be modified so that vcpkg can be run from within a shell. Open the Windows System Environment Variables dialog, and scroll through the variables and find 'Path', and select Edit. In the Edit dialog select New, and enter the complete path to the vcpkg directory. Note: This should be the same path as you set for VCPKG_ROOT.

Select OK to close the dialogs.

vcpkg is now set up for use on your machine.

Acquire and build Boost through VCPKG

See vcpkg boost

Building Boost with vcpkg is fairly simple. From the x64 Native Tools Command Prompt for VS 2022 command prompt, change into your vcpkg root directory and run the following command:

./vcpkg install boost

Alternatively, you can build and install only the packages necessary for WindNinja:

./vcpkg install boost-date-time

./vcpkg install boost-program-options

./vcpkg install boost-test

Acquire and build GDAL

See vcpkg GDAL

Building GDAL with vcpkg is fairly simple. From the x64 Native Tools Command Prompt for VS 2022 command prompt, change into your vcpkg root directory and run the following command:

./vcpkg install gdal

If all goes well you should now have boost and GDAL ready for use when building WindNinja for 64 bit Windows

Building WindNinja C_API and WindNinja_cli

Clone the WindNinja repo

From the x64 Native Tools Command Prompt for VS 2022 command prompt, change into your repositories root directory. Create a 'windninja' directory, change into it, and clone WindNinja:

md windninja

cd windninja

git clone https://github.com/firelab/windninja.git

NOTE: As of 11/19/2024, these instructions only work with the useVCPKG branch of WindNinja

Now create a build directory and change into that directory:

md build

cd build

Now run cmkae-gui to configure and generate WIndNinja for the build:

cmake-gui ..\windninja

In cmake-gui, you should be presented with a dialog to 'Specify the generator for this project'. If not, select File->Delete Cache and select 'Configure'

In the 'Specify the generator for this project' dialog, select 'NMake Makefiles' and then select 'Specify toolchain file for cross-compiling'

Select 'Next'

'Specify the Toolchain file' should appear. You need to enter or browse to the vcpkg.cmake file generated and maintained by vcpkg. The path to this file should be [VCPKG_ROOT]/scripts/buildsystems/vcpkg.cmake

In my case VCPKG_ROOT is D:\Repos\vcpkg', so the entry is:

D:\Repos\vcpkg\scripts\buildsystems\vcpkg.cmake

Once you have the Toolchain file entry completed select 'Finish'. This will automatically start the 'Configure' process.

Now you should be able to configure WindNinja to produce the WindNinjadll.dll necessary for FlamMap/Farsite use. Note that you may also be able to configure for building the full GUI, and with FOAM, but FlamMap/Farsite use a very minimal set of options in WindNinja and thus presented here are the settings for the minimal build needed by FlamMap/Farsite.

Set the following values:

  • USE_VCPKG to checked
  • NINJA_QTGUI to unchecked

Click 'Configure'

Set the following values:

  • C_API to checked
  • CURL_USE_PKGCONFIG to unchecked
  • BUILD_TESTING to unchecked
  • ENABLE_GMTED to unchecked
  • NINJAFOAM to unchecked
  • NOMADS_ENABLE_ASYNC to unchecked
  • OPENMP_SUPPORT to unchecked
  • PHONE_HOME_QUERIES to unchecked
  • WITH_LCP_CLIENT to unchecked
  • WITH_NOMADS_SUPPORT to unchecked
  • DISABLE_THREDDS_UPDATE to checked

Click 'Configure'

The output should read 'Configuring done'.

You will most likely receive some warnings but these can most likely be ignored. Most common are warnings about CMAKE version and Policy CMP0167 Any other warnings you should probably investigate!

Optional - Setting an Install Directory

It is likely best to set an install directory so that it is easy to set paths for FireModels to find WindNinjadll and necessary headers and the import library. To do this set the CMAKE_INSTALL_PREFIX to the desired location. For example, you can set it to /Repos/WindNinja/install and cmake will set up for install necessary folders and files into that directory.

Click 'Generate' If the output reads 'Generating done' you are free to exit cmake-gui and build WindNinja for FlamMap/Farsite

Build WindNinja

From the build directory, type:

nmake

WindNinja should build without errors.

If the build was successful you can now install windninjadll C API for development use:

nmake install

This will build WindNinja C API and install the necessary file under the CMAKE_INSTALL_PREFIX directory.