////
$Id: README.WIN32 12975 2014-03-03 23:11:13Z pwessel $
////

** HOWTO install GMT5 on Windows using CMake **

== Runtime dependencies

Ghostscript
===========

Install a recent Ghostscript version. We recommend the 32 bit version from
http://www.ghostscript.com/download/gsdnld.html

== Build dependencies

Microsoft Windows SDK
=====================

Note: You don't need Visual Studio 2010. Be aware, that Visual Studio 2010
Express cannot compile x64 binaries. You need the Windows SDK for that.

Download and install Microsofts free SDK for Windows, e.g. v7.1:
http://www.microsoft.com/download/en/details.aspx?id=8279

CMake
=====

Install CMake and select option to add CMake to the system PATH.
http://www.cmake.org/cmake/resources/software.html

Subversion
==========

You need to install Subversion in order to fetch the sources. Make sure svn is
in the PATH. A Windows version is available here: http://alagazam.net/

netCDF
======

Update: Unidata officially provides CMake support since netCDF 4.3.0
(http://www.unidata.ucar.edu/software/netcdf/docs/netCDF-CMake.html).

Compiling netCDF from scratch on Windows is not an easy task since you need a
lot of dependencies. You could either install a prepackaged development build
from http://www.gfd-dennou.org/arch/ucar/netcdf/contrib/win32/. For instance
netcdf-4.1.1-win32-bin.zip, and hope that it works. Most certainly it will
just not. Hence, we suggest you build netCDF yourself.

Note: In the following examples we assume that dependent libraries are
installed in sudirectories of z:\software\ any other directory is fine
though.

Obtain the CMake bundled sources of netCDF via subversion from
svn://gmtserver.soest.hawaii.edu/gmt5/sandbox/win32-dev/netcdf-4.1.3 and follow
the instructions in README.CMake in the netcdf-4.1.3 directory.

[...]

OK, well done. You successfully finished installing all required dependencies
for GMT. If you don't need PCRE and GDAL than you are all ready to build GMT!


PCRE (optional)
===============

Get PCRE from http://www.pcre.org/ and extract pcre-8.30.zip in
z:\software\src\pcre-8.30\

- Open the SDK Command Prompt:

  cd z:\software\src\pcre-8.30\
  mkdir build
  cd build
  cmake -G "NMake Makefiles" -DCMAKE_INSTALL_PREFIX=z:\software -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON ..
  nmake install

- Check if you can run 'pcregrep' from the command prompt.


GDAL (optional)
===============

We assume that you already installed HDF4, HDF5, cURL, netCDF to z:\software.
If that is not the case get the sources of netCDF for Windows from
svn://gmtserver.soest.hawaii.edu/gmt5/sandbox/win32-dev/netcdf-4.1.3
and follow the instructions in README.CMake in the source directory.

Now that all dependent libraries are available we can proceed with GDAL. In
the following we assume that the target install directory for GDAL is
z:\software as well.

- Get the GDAL sources from http://trac.osgeo.org/gdal/wiki/DownloadSource

- Extract gdal190.zip in z:\software\src\gdal-1.9.0

- Create a file z:\software\src\gdal-1.9.0\nmake.local with the following
  content:

--------8<-------------------------------------------------------

MSVC_VER       = 1600
WARNFLAGS      = /w
WIN64          = YES

GDAL_HOME      = z:\software

HDF4_PLUGIN    = NO
HDF4_DIR       = "c:\Program Files\HDF Group\HDF4\4.2.7"
HDF4_LIB       = /LIBPATH:$(HDF4_DIR)\lib hdfdll.lib mfhdfdll.lib

HDF5_PLUGIN    = NO
HDF5_DIR       = "c:\Program Files\HDF Group\HDF5\1.8.8"
HDF5_LIB       = /LIBPATH:$(HDF5_DIR)\lib hdf5dll.lib

PCIDSK_SETTING = OLD

NETCDF_PLUGIN  = NO
NETCDF_SETTING = yes
NETCDF_LIB     = z:\software\lib\netcdf.lib
NETCDF_INC_DIR = z:\software\include
NETCDF_HAS_NC4 = yes

CURL_DIR       = z:\software
CURL_INC       = -I$(CURL_DIR)\include
CURL_LIB       = $(CURL_DIR)\lib\libcurl_imp.lib Ws2_32.lib

------------------------------------------------------->8--------

Change the options according to your local setup. If unsure check the defaults
in nmake.opt.

- Open Windows SDK Command Prompt

  cd z:\software\src\gdal-1.9.0\
  nmake /f makefile.vc
  nmake /f makefile.vc devinstall

- Make sure z:\software\bin is in the PATH and type 'ogr2ogr'.
  It should greet you with usage information if everything is fine.


NSIS  (optional)
================

You also need to install NSIS (Nullsoft Scriptable Install System) if you want
to bundle GMT with all dependent DLLs and create a Windows intaller.

Download from http://nsis.sourceforge.net/


== Building GMT5

Finally we are ready to compile GMT5.

- Get GMT and GSHHG (Shoreline Database) from http://gmt.soest.hawaii.edu/

- In the source tree copy cmake/ConfigUserTemplate.cmake to
  cmake/ConfigUser.cmake and edit the file according to your demands. This is
  an example:

  set (CMAKE_INSTALL_PREFIX z:/software/gmt5msc)
  set (GSHHG_ROOT z:/software/src/gshhg-gmt)
  set (NETCDF_ROOT z:/software)
  set (GDAL_ROOT z:/software)
  set (PCRE_ROOT z:/software)

- Open Windows SDK Command Prompt

  set PATH=%PATH%;z:\software\bin
  mkdir build
  cd build

  cmake -G "NMake Makefiles" ..

  nmake
  nmake docs_html
  nmake install

- Typing 'gmt' should get you with a short message. You need to set your PATH
  to the directory specified in CMAKE_INSTALL_PREFIX:

  set PATH=%PATH%;z:\software\gmt5msc\bin

Congratulations you managed to install GMT5 on your machine!


Packaging with NSIS (optional)
==============================

Note: If you just want to create a GMT package you do not need to 'nmake
install' above.

CPack supports stand-alone ZIP archives and NSIS installers on Windows. After
building GMT run:

  nmake package

This will create both a ZIP archive and NSIS installer. If there are no issues
then you will obtain three files, e.g.:

GMT-5.x.x-win64-Documentation.zip
GMT-5.x.x-win64-Runtime.zip
GMT-5.x.x-win64.exe

Dependency walking takes a long time so be patient. You can save some time if
you are only interested in one of the two package options. Invoke CPack
instead:

  cpack -G <ZIP|NSIS>

The software packages are self contained and already include all dependent
DLLs (netCDF, GDAL, PCRE, ...).

Enjoy!

The GMT Team

////
vim: ft=asciidoc tw=78 et ts=2 sts=2 sw=2 autoindent smartindent
////
