************************************************************************
* Build and Install HDF5 REGION HL Library with CMake                  *
************************************************************************

Notes: This short instruction is written for users who want to quickly build 
       HDF5 REGION HL Library from the HDF5 REGION HL source code package using 
       the CMake tools.
       
       More information about using CMake can be found at the KitWare 
       site, www.cmake.org.
         
       CMake uses the command line; however, the visual CMake tool is 
       available for the configuration step. The steps are similar for
       all of the operating systems supported by CMake.
       
       NOTES:
         1. Using CMake for building and using HDF5  REGION HL is under active 
            development. While we have attempted to provide error-free 
            files, please understand that development with CMake has not 
            been extensively tested outside of HDF. The CMake specific 
            files may change before the next release.
            
         2. CMake for HDF5 REGION HL development should be usable on any system 
            where CMake is supported. Please send us any comments on how 
            CMake support can be improved on any system. 
            

========================================================================
I. Preconditions                                                           
========================================================================

   1. We suggest you obtain the latest CMake for windows from the Kitware
      web site. The HDF5 REGION HL product requires a minimum CMake version 
      of 2.8.10.                     
                                                                         
   2. You have installed the HDF5 library built with CMake, by executing 
      the HDF Install Utility (the *.exe file in the binary package for 
      Windows). If you are using a Windows platform, you can obtain a 
      pre-built Windows binary from The HDF Group's website at 
      www.hdfgroup.org.

   3. Set the environment variable HDF5_DIR to the installed location of 
      the config files for HDF5. On Windows: 
            HDF5_DIR=C:/Program Files/HDF_Group/HDF5/1.8.x/cmake/hdf5
      
      (Note there are no quote characters used on Windows and all platforms
      use forward slashes)

   4. Created separate source and build directories, in source builds are
      not allowed.
      (CMake commands are executed in the build directory)



========================================================================
II. Building HDF5 REGION HL Library with CMake
========================================================================

  0. Quick installation guides:


   0.1 [UNIX] ** LINKING TO A CMAKE BUILD VERSION OF HDF5 **

      The following example script can be modified to quickly compile the 
      REGION HL Library for unix, where cmake was used to build the hdf5
      library:
 
      -------- start script --------

#!/bin/csh
#
# NOTE: Modify variables denoted by the angle brackets,<>,
# to fit the build for your system.
#
# (1) Set the path to the same compilers that were used 
#     for building HDF5:
#setenv FC <path to Fortran Compiler>/gfortran
#setenv CC <path to Fortran Compiler>/gcc

#For example (Centos 6):
setenv FC gfortran
setenv CC gcc

# (2) Set the directory where hdf5 was installed. For example, 
#    if CMAKE_INSTALL_PREFIX=/build was used to build HDF5 then 
#    HDF5_DIR would be for a shared build:
#    setenv HDF5_DIR /build/share/cmake/hdf5
#
setenv HDF5_DIR <path to hdf5 installed directory>/hdf5

# set the library path for hdf5
setenv LD_LIBRARY_PATH <CMAKE_INSTALL_PREFIX>/lib

# (3) run C make; <sourcepath> is the source path to the HL region library
cmake -G "Unix Makefiles" \
-DUSE_SHARED_LIBS:BOOL=ON \
-DBUILD_TESTING:BOOL=ON \
-DHDF_BUILD_FORTRAN:BOOL=ON \
-DHDF5_BUILD_FORTRAN:BOOL=ON  \
-DHDF5_ENABLE_F2003:BOOL=ON  \
-DHDF5_BUILD_TOOLS:BOOL=ON \
-DCMAKE_INSTALL_PREFIX:PATH=./HL_JPSS \
<sourcepath>

      -------- end script --------

      After running the script do:
      make
      make install
      ctest .


   0.1 [UNIX] ** LINKING TO AUTOTOOLS BUILD VERSION OF HDF5 **

      The following example script can be modified to quickly compile the 
      REGION HL Library for unix, where configure was used to build the hdf5
      library:
 
      -------- start script --------

#!/bin/csh
#
# NOTE: Modify variables denoted by the angle brackets,<>,
# to fit the build for your system.
#
# (1) Set the path to the same compilers that were used 
#     for building HDF5:
#setenv FC <path to Fortran Compiler>/gfortran
#setenv CC <path to Fortran Compiler>/gcc

#For example (Centos 6):
setenv FC gfortran
setenv CC gcc

# (2) Set the directory where hdf5 is installed:
setenv HDF5_ROOT <path to hdf5 installed directory>/hdf5

# set the library path for hdf5 (should not need to change)
setenv LD_LIBRARY_PATH ${HDF5_ROOT}/lib

# (3) Run C make; <sourcepath> is the source path to the HL region library
#  
cmake -G "Unix Makefiles" \
-DUSE_SHARED_LIBS:BOOL=ON \
-DBUILD_TESTING:BOOL=ON \
-DHDF_BUILD_FORTRAN:BOOL=ON \
-DHDF5_BUILD_FORTRAN:BOOL=ON  \
-DHDF5_ENABLE_F2003:BOOL=ON  \
-DCMAKE_INSTALL_PREFIX:PATH=./HL_JPSS \
<sourcepath>

      -------- end script --------

      After running the script do:
      make
      make install
      ctest .

   0.3 [WINDOWS]

      The following windows batch file (.bat) can be modified to quickly 
      compile the HL Library for Windows, place the script in a different
      directory then the source:

       -------- start script --------

@echo OFF
:: Set the HDF5 install directory
SET HDF5_DIR=/Program Files/HDF_Group/HDF5/1.8.14/cmake/hdf5
:: Run the cmake command
cmake -G "Visual Studio 12 2013 Win64" ^
 -DUSE_SHARED_LIBS:BOOL=OFF ^
 -DBUILD_TESTING:BOOL=ON ^
 -DHDF5_BUILD_TOOLS:BOOL=ON ^
 -DHDF_BUILD_FORTRAN:BOOL=OFF ^
 -DHDF5_BUILD_FORTRAN:BOOL=OFF ^
 -DHDF5_PACKAGE_NAME:STRING="hdf5" ^
 <sourcepath, use Window's convention>
 
cmake --build . --config Release
ctest . -C release
     
       -------- end script --------

     The resulting REGION HL library will be placed in .\bin\Release where '.'
     represents the directory containing the .bat file.
   

   ------------- GENERAL INSTALLATION GUIDE -------------

Go through these steps to build HDF5 applications with CMake.

   1. Run CMake
   2. Configure the cache settings
   3. Test HDF5 test and example programs.

These steps are described in more detail below.

   1. Run CMake

      The visual CMake executable is named "cmake-gui.exe" on Windows and should be
      available in your Start menu. For Linux, UNIX, and Mac users the
      executable is named "cmake-gui" and can be found where CMake was 
      installed. 
      
      Specify the source and build directories. Make the build and source 
      directories different. For example on Windows, if the source is at 
      c:\MyHDFstuff\hljpss, then use c:\MyHDFstuff\hljpss\build for the build directory. 
      
      PREFERRED:
        Users can perform the configuration step without using the visual 
        cmake-gui program. The following is an example command line 
        configuration step executed within the build directory:
        
        cmake -G "<generator>"  [-D<options>]  <sourcepath>
        
        Where <generator> is    
            * Borland Makefiles
            * MSYS Makefiles
            * MinGW Makefiles
            * NMake Makefiles
            * Unix Makefiles
            * Visual Studio 11
            * Visual Studio 11 Win64
            * Visual Studio 10
            * Visual Studio 10 Win64
            * Visual Studio 6
            * Visual Studio 7
            * Visual Studio 7 .NET 2003
            * Visual Studio 8 2005
            * Visual Studio 8 2005 Win64
            * Visual Studio 9 2008
            * Visual Studio 9 2008 Win64

        <options> is:
            * BUILD_TESTING:BOOL:BOOL=[ON | OFF]
            * BUILD_STATIC_EXECS:BOOL=[ON | OFF]
	    * BUILD_SHARED_LIBS:BOOL=[ON | OFF]
	    * HDF5_DIR:PATH=<path to hdf5 cmake install directory> 
	    * HDF5_PACKAGE_NAME:STRING=hdf5
	    * HDF5_BUILD_FORTRAN:BOOL=[ON | OFF]

   2. Configure the cache settings

      2.1  Visual CMake users, click the Configure button. If this is the first time you are 
           running cmake-gui in this directory, you will be prompted for the 
           generator you wish to use (for example on Windows, Visual Studio 10). 
           CMake will read in the CMakeLists.txt files from the source directory and 
           display options for the REGION HL project. After the first configure you 
           can adjust the cache settings and/or specify locations of other programs.
      
           Any conflicts or new values will be highlighted by the configure
           process in red. Once you are happy with all the settings and there are no 
           more values in red, click the Generate button to produce the appropriate 
           build files. 
      
           On Windows, if you are using a Visual Studio generator, the solution and 
           project files will be created in the build folder.
      
           On linux, if you are using the Unix Makefiles generator, the Makefiles will
           be created in the build folder.

      2.2  Alternative command line example on Windows in c:\MyHDFstuff\hdf5\build directory:
      
           See Section 0.2

   3. Build REGION HL examples
   
      On Windows, you can build REGION HL applications using either the Visual Studio Environment 
      or the command line. The command line is normally used on linux, Unix, and Mac.

      To build from the command line, navigate to your build directory and
      execute the following:
          
              cmake --build . --config {Debug | Release}     
              
      NOTE: "--config {Debug | Release}" may be optional on your platform. We
            recommend choosing either Debug or Release on Windows. If you are
            using the pre-built binaries from HDF, use Release.                                                                                     
             
      3.1  If you wish to use the Visual Studio environment, open the solution 
           file in your build directory. Be sure to select either Debug or 
           Release and build the solution.
             
   4. Test HDF5 Examples.

      To test the build, navigate to your build directory and execute:
      
              ctest . -C {Debug | Release}
              
      NOTE: "-C {Debug | Release}" may be optional on your platform. We
            recommend choosing either Debug or Release to match the build
            step on Windows.                                                                                      

   5. The files that support building with CMake are all of the files in the 
      config/cmake folder, the CMakeLists.txt files in each source folder, and 
      CTestConfig.cmake. CTestConfig.cmake is specific to the internal testing 
      performed by The HDF Group. It should be altered for the user's 
      installation and needs.

************************************************************************

Need further assistance, send email to help@hdfgroup.org

