************************************************************************
* Build and Test HDF4 Examples with CMake                              *
************************************************************************

Notes: This short instruction is written for users who want to quickly
       test the installation of HDF4 by using the CMake tools to build
       and test the HDF4 Examples. The following instructions will show
       the default usage and then present common changes for non-default
       installations.
       For more information, see the USING_HDF4_CMake.txt file.

       More information about using CMake can be found at the Kitware
       site, www.cmake.org.

                     Table of Contents

Section I:    Preconditions
Section II:   Building HDF4 Examples with CMake
              1. Using presets
              2. Using CTestScript.cmake
Section III:  Defaults in the CMakePresets.json file
Section IV:   Defaults in the HDF4_Examples_options.cmake file


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

   1. We suggest you obtain the latest CMake for your platform from the Kitware
      web site. The HDF 4.3.x product requires a minimum CMake version
      of 3.18. If you are using VS2022, the minimum CMake version is 3.21.
      CMakePresets.json, requires CMake 3.25 or higher.

   2. You have installed the HDF4 library built with CMake, by executing
      the HDF Install Utility (the *.msi file in the binary package for
      Windows or the *.sh on Linux). You can obtain pre-built binaries
      from The HDF Group's website at www.hdfgroup.org.

    3. Set the HDF4_ROOT CMake variable, -DHDF4_ROOT=<install_path>
        or environment variable, set(ENV{HDF4_ROOT} "<install_path>")
         to the installed location of HDF4.
             On Windows:
                 HDF4_ROOT=C:/Program Files/HDF_Group/HDF4/z.y.x/
             On unix:
                 HDF4_ROOT=<install root folder>/HDF_Group/HDF4/z.y.x/

         If you are using shared libraries, you may need to add to the path
         environment variable. Set the path environment variable to the
         installed location of the library files for HDF4.
             On Windows (*.dll):
                 PATH=%PATH%;C:/Program Files/HDF_Group/HDF4/z.y.x/bin
             On unix (*.so):
                 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:<install root folder>/HDF_Group/HDF4/z.y.x/lib

         (Note there are no quote characters used on Windows and all platforms
         use forward slashes)

========================================================================
II. Building HDF4 Examples with CMake
========================================================================

  1. Using presets
    Files in the HDF4 install/HDF5Examples directory:
       CMakePresets.json

    Default build process:
         Create a directory to run the examples, i.e. \test_hdf4.
         Copy the HDF4Examples folder to this directory.
         Change into the HDF4Examples directory where CMakePresets.json exists.

         Other options can be changed by creating a
              CMakeUsersPresets.json file. (Advanced usage)

    Available configurations presets can be displayed by executing:
        cmake -S <path-to-source> --list-presets

    Using individual command presets (where <compiler-type> is  GNUC or MSVC or Clang):
        cmake --preset ci-StdShar-<compiler-type>
        cmake --build --preset ci-StdShar-<compiler-type>
        ctest --preset ci-StdShar-<compiler-type>
        cpack --preset ci-StdShar-<compiler-type>

    Using the workflow preset to configure, build, and testthe standard configuration:
        execute "cmake --workflow --preset ci-StdShar-<compiler-type> --fresh"
              where <compiler-type> is  GNUC or MSVC or Clang

  2. Using CTestScript.cmake
    Files in the HDF4 install directory:
       HDF4Examples folder
       CTestScript.cmake
       HDF4_Examples.cmake
       HDF4_Examples_options.cmake

    Default build process:
       Create a directory to run the examples, i.e. \test_hdf4.
       Copy HDF4Examples folder to this directory.
       Copy CTestScript.cmake to this directory.
       Copy HDF4_Examples.cmake to this directory.
       Copy HDF4_Examples_options.cmake to this directory.
       The default source folder is defined as "HDF4Examples". It can be changed
           with the CTEST_SOURCE_NAME script option.
       The default installation folder is defined for the platform.
           It can be changed with the INSTALLDIR script option.
           (Note: Windows has issues with spaces and paths -The path will need to
            be set correctly.)
       The default ctest configuration is defined as "Release". It can be changed
           with the CTEST_CONFIGURATION_TYPE script option. Note that this must
           be the same as the value used with the -C command line option.
           On Windows, you can set the CTEST_VSVERS script option to either
               64_VS2022 or 64_VS2019. Alternately, you can set the script
               CTEST_CMAKE_GENERATOR option to "Visual Studio 16 2019" or "Visual Studio 17 2022",
               and the CMAKE_GENERATOR_ARCHITECTURE script option to "x64".

       The default build configuration is defined to build and use static libraries.
           Shared libraries can be used with the STATIC_ONLY script option set to "NO".

       Shared libraries and other options can be changed by editing the
           HDF4_Examples_options.cmake file.

       If the defaults are okay, execute from this directory:
           ctest -S HDF4_Examples.cmake -C Release -VV -O test.log
       If the defaults need change, execute from this directory:
           ctest -S HDF4_Examples.cmake,CTEST_SOURCE_NAME=MyExamples,INSTALLDIR=MyLocation -C Release -VV -O test.log

    When executed, the ctest script will save the results to the log file, test.log, as
    indicated by the ctest command. If you wish to see more build and test information,
    add "-VV" to the ctest command. The output should show;
          100% tests passed, 0 tests failed out of 49.


========================================================================
III. Defaults in the CMakeUsersPresets.json file
========================================================================

####  DEFAULT:
####      "generator": "Ninja"
####      "binaryDir": "${sourceParentDir}/build/${presetName}"
####      "name": "ci-StdShar"
####        "BUILD_SHARED_LIBS": "ON",
####        "USE_SHARED_LIBS": "ON"
####        "CMAKE_BUILD_TYPE": "RelWithDebInfo"
####        "H4EX_BUILD_FORTRAN": "OFF"
####        "H4EX_BUILD_JAVA": "ON"
####        "HDF4_NAMESPACE": {"type": "STRING", "value": "hdf4::"},
####        "HDF4_PACKAGE_NAME": {"type": "STRING", "value": "hdf4"},
####        "H4EX_BUILD_TESTING": "ON"


========================================================================
IV. Defaults in the HDF4_Examples_options.cmake file
========================================================================

####  DEFAULT:
####         BUILD_SHARED_LIBS:BOOL=OFF
####         H4EX_BUILD_C:BOOL=ON
####         H4EX_BUILD_FORTRAN:BOOL=OFF
####         H4EX_BUILD_JAVA:BOOL=OFF
####         H4EX_BUILD_TESTING:BOOL=OFF

