summaryrefslogtreecommitdiffstats
path: root/HDF5Examples/config
diff options
context:
space:
mode:
Diffstat (limited to 'HDF5Examples/config')
-rw-r--r--HDF5Examples/config/cmake-presets/hidden-presets.json393
-rw-r--r--HDF5Examples/config/cmake/CMakeFindJavaCommon.cmake30
-rw-r--r--HDF5Examples/config/cmake/CTestCustom.cmake11
-rw-r--r--HDF5Examples/config/cmake/HDFExampleMacros.cmake368
-rw-r--r--HDF5Examples/config/cmake/HDFMacros.cmake209
-rw-r--r--HDF5Examples/config/cmake/UseJava.cmake1654
-rw-r--r--HDF5Examples/config/cmake/UseJavaClassFilelist.cmake39
-rw-r--r--HDF5Examples/config/cmake/UseJavaSymlinks.cmake16
-rw-r--r--HDF5Examples/config/cmake/cacheinit.cmake27
-rw-r--r--HDF5Examples/config/cmake/grepTest.cmake213
-rw-r--r--HDF5Examples/config/cmake/jrunTest.cmake305
-rw-r--r--HDF5Examples/config/cmake/runTest.cmake387
-rw-r--r--HDF5Examples/config/toolchain/aarch64.cmake17
-rw-r--r--HDF5Examples/config/toolchain/build32.cmake79
-rw-r--r--HDF5Examples/config/toolchain/clang.cmake16
-rw-r--r--HDF5Examples/config/toolchain/crayle.cmake10
-rw-r--r--HDF5Examples/config/toolchain/gcc.cmake11
-rw-r--r--HDF5Examples/config/toolchain/icc.cmake11
-rw-r--r--HDF5Examples/config/toolchain/intel.cmake11
-rw-r--r--HDF5Examples/config/toolchain/mingw64.cmake14
-rw-r--r--HDF5Examples/config/toolchain/pgi.cmake11
21 files changed, 3832 insertions, 0 deletions
diff --git a/HDF5Examples/config/cmake-presets/hidden-presets.json b/HDF5Examples/config/cmake-presets/hidden-presets.json
new file mode 100644
index 0000000..883b903
--- /dev/null
+++ b/HDF5Examples/config/cmake-presets/hidden-presets.json
@@ -0,0 +1,393 @@
+{
+ "version": 6,
+ "configurePresets": [
+ {
+ "name": "ci-base",
+ "displayName": "Basic Config",
+ "description": "Basic build using Ninja generator",
+ "generator": "Ninja",
+ "hidden": true,
+ "binaryDir": "${sourceParentDir}/build/${presetName}",
+ "installDir": "${sourceParentDir}/install/${presetName}"
+ },
+ {
+ "name": "ci-x64",
+ "architecture": {
+ "value": "x64",
+ "strategy": "external"
+ },
+ "hidden": true
+ },
+ {
+ "name": "ci-x86",
+ "architecture": {
+ "value": "x86",
+ "strategy": "external"
+ },
+ "hidden": true
+ },
+ {
+ "name": "ci-Debug",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug"
+ },
+ "hidden": true
+ },
+ {
+ "name": "ci-Release",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo"
+ },
+ "hidden": true
+ },
+ {
+ "name": "ci-MSVC",
+ "hidden": true,
+ "cacheVariables": {
+ "CMAKE_C_COMPILER": "cl",
+ "CMAKE_CXX_COMPILER": "cl"
+ },
+ "toolset": {
+ "value": "host=x64",
+ "strategy": "external"
+ },
+ "condition": {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Windows"
+ }
+ },
+ {
+ "name": "ci-Clang",
+ "hidden": true,
+ "cacheVariables": {
+ "CMAKE_TOOLCHAIN_FILE": "config/toolchain/clang.cmake"
+ },
+ "toolset": {
+ "value": "host=x64",
+ "strategy": "external"
+ }
+ },
+ {
+ "name": "ci-GNUC",
+ "hidden": true,
+ "cacheVariables": {
+ "CMAKE_TOOLCHAIN_FILE": "config/toolchain/gcc.cmake"
+ },
+ "condition": {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Linux"
+ },
+ "toolset": {
+ "value": "host=x64",
+ "strategy": "external"
+ }
+ },
+ {
+ "name": "ci-Intel",
+ "hidden": true,
+ "cacheVariables": {
+ "CMAKE_TOOLCHAIN_FILE": "config/toolchain/intel.cmake"
+ },
+ "toolset": {
+ "value": "host=x64",
+ "strategy": "external"
+ }
+ },
+ {
+ "name": "ci-x64-Debug-MSVC",
+ "description": "MSVC for x64 (Debug)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Debug",
+ "ci-MSVC"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-MSVC",
+ "description": "MSVC for x64 (Release)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Release",
+ "ci-MSVC"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-Clang",
+ "description": "Clang/LLVM for x64 (Debug)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Debug",
+ "ci-Clang"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-Clang",
+ "description": "Clang/LLVM for x64 (Release)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Release",
+ "ci-Clang"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-GNUC",
+ "description": "GNUC for x64 (Debug)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Debug",
+ "ci-GNUC"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-GNUC",
+ "description": "GNUC for x64 (Release)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Release",
+ "ci-GNUC"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-Intel",
+ "description": "Intel for x64 (Debug)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Debug",
+ "ci-Intel"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-Intel",
+ "description": "Intel for x64 (Release)",
+ "hidden": true,
+ "inherits": [
+ "ci-base",
+ "ci-x64",
+ "ci-Release",
+ "ci-Intel"
+ ]
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "ci-base",
+ "configurePreset": "ci-base",
+ "hidden": true,
+ "verbose": true,
+ "jobs": 8
+ },
+ {
+ "name": "ci-x64-Debug-MSVC",
+ "configurePreset": "ci-x64-Debug-MSVC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ],
+ "configuration": "Debug"
+ },
+ {
+ "name": "ci-x64-Release-MSVC",
+ "configurePreset": "ci-x64-Release-MSVC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ],
+ "configuration": "RelWithDebInfo"
+ },
+ {
+ "name": "ci-x64-Debug-Clang",
+ "configurePreset": "ci-x64-Debug-Clang",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-Clang",
+ "configurePreset": "ci-x64-Release-Clang",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-GNUC",
+ "configurePreset": "ci-x64-Debug-GNUC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-GNUC",
+ "configurePreset": "ci-x64-Release-GNUC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-Intel",
+ "configurePreset": "ci-x64-Debug-Intel",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ],
+ "configuration": "Debug"
+ },
+ {
+ "name": "ci-x64-Release-Intel",
+ "configurePreset": "ci-x64-Release-Intel",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ],
+ "configuration": "RelWithDebInfo"
+ }
+ ],
+ "testPresets": [
+ {
+ "name": "ci-base",
+ "configurePreset": "ci-base",
+ "output": {
+ "outputOnFailure": false,
+ "shortProgress": true,
+ "verbosity": "verbose"
+ },
+ "hidden": true,
+ "execution": {
+ "noTestsAction": "error",
+ "timeout": 600,
+ "jobs": 8
+ }
+ },
+ {
+ "name": "ci-x64-Debug-MSVC",
+ "configurePreset": "ci-x64-Debug-MSVC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ],
+ "configuration": "Debug"
+ },
+ {
+ "name": "ci-x64-Release-MSVC",
+ "configurePreset": "ci-x64-Release-MSVC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ],
+ "configuration": "RelWithDebInfo"
+ },
+ {
+ "name": "ci-x64-Debug-Clang",
+ "configurePreset": "ci-x64-Debug-Clang",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-Clang",
+ "configurePreset": "ci-x64-Release-Clang",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-GNUC",
+ "configurePreset": "ci-x64-Debug-GNUC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-GNUC",
+ "configurePreset": "ci-x64-Release-GNUC",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Debug-Intel",
+ "configurePreset": "ci-x64-Debug-Intel",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-Intel",
+ "configurePreset": "ci-x64-Release-Intel",
+ "hidden": true,
+ "inherits": [
+ "ci-base"
+ ]
+ }
+ ],
+ "packagePresets": [
+ {
+ "name": "ci-base",
+ "hidden": true,
+ "output": {
+ "verbose": true
+ }
+ },
+ {
+ "name": "ci-x64-Release-MSVC",
+ "configurePreset": "ci-x64-Release-MSVC",
+ "hidden": true,
+ "inherits": "ci-base",
+ "generators": [
+ "ZIP"
+ ],
+ "configurations": ["RelWithDebInfo"]
+ },
+ {
+ "name": "ci-x64-Release-Clang",
+ "configurePreset": "ci-x64-Release-Clang",
+ "hidden": true,
+ "inherits": "ci-base",
+ "generators": [
+ "TGZ"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-GNUC",
+ "configurePreset": "ci-x64-Release-GNUC",
+ "hidden": true,
+ "inherits": "ci-base",
+ "generators": [
+ "TGZ"
+ ]
+ },
+ {
+ "name": "ci-x64-Release-Intel",
+ "configurePreset": "ci-x64-Release-Intel",
+ "hidden": true,
+ "inherits": "ci-base",
+ "generators": [
+ "TGZ"
+ ]
+ }
+ ]
+}
diff --git a/HDF5Examples/config/cmake/CMakeFindJavaCommon.cmake b/HDF5Examples/config/cmake/CMakeFindJavaCommon.cmake
new file mode 100644
index 0000000..528791d
--- /dev/null
+++ b/HDF5Examples/config/cmake/CMakeFindJavaCommon.cmake
@@ -0,0 +1,30 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details.
+
+
+# Do not include this module directly from code outside CMake!
+set(_JAVA_HOME "")
+if(JAVA_HOME AND IS_DIRECTORY "${JAVA_HOME}")
+ set(_JAVA_HOME "${JAVA_HOME}")
+ set(_JAVA_HOME_EXPLICIT 1)
+else()
+ set(_ENV_JAVA_HOME "")
+ if(DEFINED ENV{JAVA_HOME})
+ file(TO_CMAKE_PATH "$ENV{JAVA_HOME}" _ENV_JAVA_HOME)
+ endif()
+ if(_ENV_JAVA_HOME AND IS_DIRECTORY "${_ENV_JAVA_HOME}")
+ set(_JAVA_HOME "${_ENV_JAVA_HOME}")
+ set(_JAVA_HOME_EXPLICIT 1)
+ else()
+ set(_CMD_JAVA_HOME "")
+ if(APPLE AND EXISTS "/usr/libexec/java_home")
+ execute_process(COMMAND /usr/libexec/java_home
+ OUTPUT_VARIABLE _CMD_JAVA_HOME OUTPUT_STRIP_TRAILING_WHITESPACE)
+ endif()
+ if(_CMD_JAVA_HOME AND IS_DIRECTORY "${_CMD_JAVA_HOME}")
+ set(_JAVA_HOME "${_CMD_JAVA_HOME}")
+ set(_JAVA_HOME_EXPLICIT 0)
+ endif()
+ unset(_CMD_JAVA_HOME)
+ endif()
+ unset(_ENV_JAVA_HOME)
+endif()
diff --git a/HDF5Examples/config/cmake/CTestCustom.cmake b/HDF5Examples/config/cmake/CTestCustom.cmake
new file mode 100644
index 0000000..1021c4e
--- /dev/null
+++ b/HDF5Examples/config/cmake/CTestCustom.cmake
@@ -0,0 +1,11 @@
+set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 1500)
+
+set (CTEST_CUSTOM_WARNING_EXCEPTION
+ ${CTEST_CUSTOM_WARNING_EXCEPTION}
+ "POSIX name for this item is deprecated"
+ "disabling jobserver mode"
+)
+
+set (CTEST_CUSTOM_MEMCHECK_IGNORE
+ ${CTEST_CUSTOM_MEMCHECK_IGNORE}
+)
diff --git a/HDF5Examples/config/cmake/HDFExampleMacros.cmake b/HDF5Examples/config/cmake/HDFExampleMacros.cmake
new file mode 100644
index 0000000..d9bf67f
--- /dev/null
+++ b/HDF5Examples/config/cmake/HDFExampleMacros.cmake
@@ -0,0 +1,368 @@
+#-------------------------------------------------------------------------------
+macro (BASIC_SETTINGS varname)
+ string (TOUPPER ${varname} EXAMPLE_PACKAGE_VARNAME)
+ string (TOLOWER ${varname} EXAMPLE_VARNAME)
+ set (H5${EXAMPLE_PACKAGE_VARNAME}_PACKAGE "h5${EXAMPLE_VARNAME}")
+ set (H5${EXAMPLE_PACKAGE_VARNAME}_PACKAGE_NAME "h5${EXAMPLE_VARNAME}")
+ string (TOUPPER ${H5${EXAMPLE_PACKAGE_VARNAME}_PACKAGE_NAME} EXAMPLE_PACKAGE_NAME)
+ string (TOLOWER ${H5${EXAMPLE_PACKAGE_VARNAME}_PACKAGE_NAME} EXAMPLE_NAME)
+ set (CMAKE_NO_SYSTEM_FROM_IMPORTED 1)
+
+ #-----------------------------------------------------------------------------
+ # Define some CMake variables for use later in the project
+ #-----------------------------------------------------------------------------
+ set (${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR ${${EXAMPLE_PACKAGE_NAME}_SOURCE_DIR}/config/cmake)
+ set (${EXAMPLE_PACKAGE_NAME}_SRC_DIR ${${EXAMPLE_PACKAGE_NAME}_SOURCE_DIR}/src)
+
+ #-----------------------------------------------------------------------------
+ # Setup output Directories
+ #-----------------------------------------------------------------------------
+ if (NOT ${EXAMPLE_PACKAGE_NAME}_EXTERNALLY_CONFIGURED)
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables."
+ )
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries"
+ )
+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries."
+ )
+ set (CMAKE_Fortran_MODULE_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all fortran modules."
+ )
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig)
+ set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE})
+ set (CMAKE_PDB_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all pdb files."
+ )
+ else ()
+ set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ endif ()
+ else ()
+ # if we are externally configured, but the project uses old cmake scripts
+ # this may not be set
+ if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+ endif ()
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to use Shared/Static libs, default is static
+ #-----------------------------------------------------------------------------
+ set (LIB_TYPE STATIC)
+ if (BUILD_SHARED_LIBS)
+ set (LIB_TYPE SHARED)
+ endif ()
+ set (CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+ if (MSVC)
+ set (CMAKE_MFC_FLAG 0)
+ endif ()
+
+ set (CMAKE_C_STANDARD 99)
+ set (CMAKE_C_STANDARD_REQUIRED TRUE)
+
+ set (CMAKE_CXX_STANDARD 98)
+ set (CMAKE_CXX_STANDARD_REQUIRED TRUE)
+ set (CMAKE_CXX_EXTENSIONS OFF)
+
+ #-----------------------------------------------------------------------------
+ # Compiler specific flags : Shouldn't there be compiler tests for these
+ #-----------------------------------------------------------------------------
+ if (CMAKE_COMPILER_IS_GNUCC)
+ set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS}")
+ endif ()
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS}")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # This is in here to help some of the GCC based IDES like Eclipse
+ # and code blocks parse the compiler errors and warnings better.
+ #-----------------------------------------------------------------------------
+ if (CMAKE_COMPILER_IS_GNUCC)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fmessage-length=0")
+ endif ()
+ if (CMAKE_COMPILER_IS_GNUCXX)
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fmessage-length=0")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to allow the user to disable compiler warnings
+ #-----------------------------------------------------------------------------
+ option (HDF_DISABLE_COMPILER_WARNINGS "Disable compiler warnings" OFF)
+ if (HDF_DISABLE_COMPILER_WARNINGS)
+ # MSVC uses /w to suppress warnings. It also complains if another
+ # warning level is given, so remove it.
+ if (MSVC)
+ set (HDF_WARNINGS_BLOCKED 1)
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /w")
+ string (REGEX REPLACE "(^| )([/-])W[0-9]( |$)" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w")
+ endif ()
+ if (WIN32)
+ add_definitions (-D_CRT_SECURE_NO_WARNINGS)
+ endif ()
+ # Borland uses -w- to suppress warnings.
+ if (BORLAND)
+ set (HDF_WARNINGS_BLOCKED 1)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w-")
+ endif ()
+
+ # Most compilers use -w to suppress warnings.
+ if (NOT HDF_WARNINGS_BLOCKED)
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w")
+ endif ()
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Set includes needed for build
+ #-----------------------------------------------------------------------------
+ set (${EXAMPLE_PACKAGE_NAME}_INCLUDES_BUILD_TIME
+ ${${EXAMPLE_PACKAGE_NAME}_SRC_DIR} ${${EXAMPLE_PACKAGE_NAME}_BINARY_DIR}
+ )
+
+ #-----------------------------------------------------------------------------
+ # Option to build JAVA examples
+ #-----------------------------------------------------------------------------
+ option (HDF_BUILD_JAVA "Build JAVA support" OFF)
+ if (HDF_BUILD_JAVA)
+ find_package (Java)
+ INCLUDE_DIRECTORIES (
+ ${JAVA_INCLUDE_PATH}
+ ${JAVA_INCLUDE_PATH2}
+ )
+
+ include (${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR}/UseJava.cmake)
+ endif ()
+endmacro ()
+
+macro (HDF5_SUPPORT)
+ set (CMAKE_MODULE_PATH ${${EXAMPLE_PACKAGE_NAME}_RESOURCES_DIR} ${CMAKE_MODULE_PATH})
+ option (USE_SHARED_LIBS "Use Shared Libraries" ON)
+
+ if (NOT H5EX_HDF5_HEADER)
+ if (USE_SHARED_LIBS)
+ set (FIND_HDF_COMPONENTS C shared)
+ else ()
+ set (FIND_HDF_COMPONENTS C static)
+ set (HDF_BUILD_JAVA OFF CACHE BOOL "Build Java support" FORCE)
+ message (STATUS "Using static HDF5 - disable build of Java examples")
+ endif ()
+ if (HDF_BUILD_FORTRAN)
+ set (FIND_HDF_COMPONENTS ${FIND_HDF_COMPONENTS} Fortran)
+ endif ()
+ if (HDF_BUILD_JAVA)
+ set (FIND_HDF_COMPONENTS ${FIND_HDF_COMPONENTS} Java)
+ set (HDF5_Java_FOUND 1) #default setting for 1.10.1 and earlier
+ endif ()
+ message (STATUS "HDF5 find comps: ${FIND_HDF_COMPONENTS}")
+ set (SEARCH_PACKAGE_NAME ${HDF5_PACKAGE_NAME})
+
+ find_package (HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS ${FIND_HDF_COMPONENTS})
+ message (STATUS "HDF5 C libs:${HDF5_FOUND} static:${HDF5_static_C_FOUND} and shared:${HDF5_shared_C_FOUND}")
+ message (STATUS "HDF5 Fortran libs: static:${HDF5_static_Fortran_FOUND} and shared:${HDF5_shared_Fortran_FOUND}")
+ message (STATUS "HDF5 Java libs: ${HDF5_Java_FOUND}")
+ if (HDF5_FOUND)
+ if (USE_SHARED_LIBS)
+ if (NOT TARGET ${HDF5_NAMESPACE}h5dump-shared)
+ add_executable (${HDF5_NAMESPACE}h5dump-shared IMPORTED)
+ endif ()
+ set (H5EX_HDF5_DUMP_EXECUTABLE $<TARGET_FILE:${HDF5_NAMESPACE}h5dump-shared>)
+ else ()
+ if (NOT TARGET ${HDF5_NAMESPACE}h5dump)
+ add_executable (${HDF5_NAMESPACE}h5dump IMPORTED)
+ endif()
+ set (H5EX_HDF5_DUMP_EXECUTABLE $<TARGET_FILE:${HDF5_NAMESPACE}h5dump>)
+ endif()
+
+ if (NOT HDF5_static_C_FOUND AND NOT HDF5_shared_C_FOUND)
+ #find library from non-dual-binary package
+ set (FIND_HDF_COMPONENTS C)
+ if (HDF_BUILD_FORTRAN)
+ set (FIND_HDF_COMPONENTS ${FIND_HDF_COMPONENTS} Fortran)
+ endif ()
+ if (HDF_BUILD_JAVA)
+ set (FIND_HDF_COMPONENTS ${FIND_HDF_COMPONENTS} Java)
+ endif ()
+ message (STATUS "HDF5 find comps: ${FIND_HDF_COMPONENTS}")
+
+ find_package (HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS ${FIND_HDF_COMPONENTS})
+ message (STATUS "HDF5 libs:${HDF5_FOUND} C:${HDF5_C_FOUND} Fortran:${HDF5_Fortran_FOUND} Java:${HDF5_Java_FOUND}")
+ set (H5EX_HDF5_LINK_LIBS ${H5EX_HDF5_LINK_LIBS} ${HDF5_LIBRARIES})
+ if (HDF5_BUILD_SHARED_LIBS)
+ add_definitions (-DH5_BUILT_AS_DYNAMIC_LIB)
+ else ()
+ add_definitions (-DH5_BUILT_AS_STATIC_LIB)
+ endif ()
+ if (USE_SHARED_LIBS AND WIN32)
+ set_property (TARGET ${HDF5_NAMESPACE}h5dump PROPERTY IMPORTED_LOCATION "${HDF5_TOOLS_DIR}/h5dumpdll")
+ else ()
+ set_property (TARGET ${HDF5_NAMESPACE}h5dump PROPERTY IMPORTED_LOCATION "${HDF5_TOOLS_DIR}/h5dump")
+ endif ()
+ if (HDF_BUILD_JAVA)
+ set (CMAKE_JAVA_INCLUDE_PATH "${CMAKE_JAVA_INCLUDE_PATH};${HDF5_JAVA_INCLUDE_DIRS}")
+ message (STATUS "HDF5 jars:${HDF5_JAVA_INCLUDE_DIRS}")
+ endif ()
+ set (H5EX_HDF5_DUMP_EXECUTABLE $<TARGET_FILE:${HDF5_NAMESPACE}h5dump>)
+ else ()
+ if (USE_SHARED_LIBS AND HDF5_shared_C_FOUND)
+ set (H5EX_HDF5_LINK_LIBS ${H5EX_HDF5_LINK_LIBS} ${HDF5_C_SHARED_LIBRARY})
+ set (HDF5_LIBRARY_PATH ${PACKAGE_PREFIX_DIR}/lib)
+ set_property (TARGET ${HDF5_NAMESPACE}h5dump-shared PROPERTY IMPORTED_LOCATION "${HDF5_TOOLS_DIR}/h5dump-shared")
+ else ()
+ set (H5EX_HDF5_LINK_LIBS ${H5EX_HDF5_LINK_LIBS} ${HDF5_C_STATIC_LIBRARY})
+ set_property (TARGET ${HDF5_NAMESPACE}h5dump PROPERTY IMPORTED_LOCATION "${HDF5_TOOLS_DIR}/h5dump")
+ endif ()
+ if (HDF_BUILD_FORTRAN AND ${HDF5_BUILD_FORTRAN})
+ if (BUILD_SHARED_LIBS AND HDF5_shared_Fortran_FOUND)
+ set (H5EX_HDF5_LINK_LIBS ${H5EX_HDF5_LINK_LIBS} ${HDF5_FORTRAN_SHARED_LIBRARY})
+ elseif (HDF5_static_Fortran_FOUND)
+ set (H5EX_HDF5_LINK_LIBS ${H5EX_HDF5_LINK_LIBS} ${HDF5_FORTRAN_STATIC_LIBRARY})
+ else ()
+ set (HDF_BUILD_FORTRAN OFF CACHE BOOL "Build FORTRAN support" FORCE)
+ message (STATUS "HDF5 Fortran libs not found - disable build of Fortran examples")
+ endif ()
+ else ()
+ set (HDF_BUILD_FORTRAN OFF CACHE BOOL "Build FORTRAN support" FORCE)
+ message (STATUS "HDF5 Fortran libs not found - disable build of Fortran examples")
+ endif ()
+ if (HDF_BUILD_JAVA)
+ if (${HDF5_BUILD_JAVA} AND HDF5_Java_FOUND)
+ set (CMAKE_JAVA_INCLUDE_PATH "${CMAKE_JAVA_INCLUDE_PATH};${HDF5_JAVA_INCLUDE_DIRS}")
+ message (STATUS "HDF5 jars:${HDF5_JAVA_INCLUDE_DIRS}}")
+ else ()
+ set (HDF_BUILD_JAVA OFF CACHE BOOL "Build Java support" FORCE)
+ message (STATUS "HDF5 Java libs not found - disable build of Java examples")
+ endif ()
+ else ()
+ set (HDF_BUILD_JAVA OFF CACHE BOOL "Build Java support" FORCE)
+ endif ()
+ endif ()
+ else ()
+ find_package (HDF5) # Legacy find
+ #Legacy find_package does not set HDF5_TOOLS_DIR, so we set it here
+ set (HDF5_TOOLS_DIR ${HDF5_LIBRARY_DIRS}/../bin)
+ #Legacy find_package does not set HDF5_BUILD_SHARED_LIBS, so we set it here
+ if (USE_SHARED_LIBS AND EXISTS "${HDF5_LIBRARY_DIRS}/libhdf5.so")
+ set (HDF5_BUILD_SHARED_LIBS 1)
+ else ()
+ set (HDF5_BUILD_SHARED_LIBS 0)
+ endif ()
+ set (H5EX_HDF5_LINK_LIBS ${H5EX_HDF5_LINK_LIBS} ${HDF5_LIBRARIES})
+ add_executable (${HDF5_NAMESPACE}h5dump IMPORTED)
+ set_property (TARGET ${HDF5_NAMESPACE}h5dump PROPERTY IMPORTED_LOCATION "${HDF5_TOOLS_DIR}/h5dump")
+ set (H5EX_HDF5_DUMP_EXECUTABLE $<TARGET_FILE:${HDF5_NAMESPACE}h5dump>)
+ endif ()
+
+ set (HDF5_PACKAGE_NAME ${SEARCH_PACKAGE_NAME})
+
+ if (HDF5_FOUND)
+ set (H5EX_HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR})
+ set (H5EX_HDF5_HAVE_H5PUBCONF_H 1)
+ set (H5EX_HDF5_HAVE_HDF5 1)
+ set (H5EX_HDF5_HEADER "h5pubconf.h")
+ message (STATUS "HDF5-${HDF5_VERSION_STRING} found: INC=${HDF5_INCLUDE_DIR} TOOLS=${HDF5_TOOLS_DIR}")
+ else ()
+ message (FATAL_ERROR " HDF5 is Required for HDF5 Examples")
+ endif ()
+ else ()
+ # This project is being called from within another and HDF5 is already configured
+ set (H5EX_HDF5_HAVE_H5PUBCONF_H 1)
+ set (H5EX_HDF5_HAVE_HDF5 1)
+ message (STATUS "HDF5-${HDF5_VERSION_STRING} used")
+ endif ()
+ if (HDF_BUILD_FORTRAN)
+ list (APPEND H5EX_HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIR_FORTRAN})
+ endif ()
+ message (STATUS "HDF5 link libs: ${H5EX_HDF5_LINK_LIBS} Includes: ${H5EX_HDF5_INCLUDE_DIRS}")
+
+ if (USE_SHARED_LIBS)
+ set (H5_LIB_TYPE SHARED)
+ else ()
+ set (H5_LIB_TYPE STATIC)
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to build filter examples
+ #-----------------------------------------------------------------------------
+ option (HDF_BUILD_FILTERS "Test filter support" OFF)
+endmacro ()
+
+#-------------------------------------------------------------------------------
+# Purpose:
+# Breaking down three numbered versions (x.y.z) into their components, and
+# returning a major and minor version (xy).
+#
+# Parameters:
+# version [in] The version string.
+# xyapi [out] A "majorminor" API version.
+#
+macro (APIVersion version xyapi)
+ string (REGEX REPLACE "(\-[0-9]+)" "" xyz ${version})
+ message (VERBOSE "version=${version}")
+
+ string (REGEX REPLACE "([0-9]+).[0-9]+.[0-9]+" "\\1" major ${xyz})
+ string (REGEX REPLACE "[0-9]+.([0-9]+).[0-9]+" "\\1" minor ${xyz})
+ string (REGEX REPLACE "[0-9]+.[0-9]+.([0-9]+)" "\\1" patch ${xyz})
+ message (VERBOSE "major=${major} minor=${minor}")
+
+ # Round up to the next major release if minor is odd-numbered
+ math (EXPR rem "${minor}%2")
+ if (NOT ${rem} STREQUAL "0")
+ math (EXPR minor "${minor} + 1")
+ endif ()
+
+ set (${xyapi} "${major}${minor}")
+
+ #-----------------------------------------------------------------------------
+ # Option to use 1.6.x API
+ #-----------------------------------------------------------------------------
+ option (${EXAMPLE_VARNAME}_USE_16_API "Use the HDF5 1.6.x API" OFF)
+ if (${EXAMPLE_VARNAME}_USE_16_API AND ${xyapi} GREATER 16)
+ set (${xyapi} "16")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to use 1.8.x API
+ #-----------------------------------------------------------------------------
+ option (${EXAMPLE_VARNAME}_USE_18_API "Use the HDF5 1.8.x API" OFF)
+ if (${EXAMPLE_VARNAME}_USE_18_API AND ${xyapi} GREATER 18)
+ set (${xyapi} "18")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to use 1.10.x API
+ #-----------------------------------------------------------------------------
+ option (${EXAMPLE_VARNAME}_USE_110_API "Use the HDF5 1.10.x API" OFF)
+ if (${EXAMPLE_VARNAME}_USE_110_API AND ${xyapi} GREATER 110)
+ set (${xyapi} "110")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to use 1.12.x API
+ #-----------------------------------------------------------------------------
+ option (${EXAMPLE_VARNAME}_USE_112_API "Use the HDF5 1.12.x API" OFF)
+ if (${EXAMPLE_VARNAME}_USE_112_API AND ${xyapi} GREATER 112)
+ set (${xyapi} "112")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to use 1.14.x API
+ #-----------------------------------------------------------------------------
+ option (${EXAMPLE_VARNAME}_USE_114_API "Use the HDF5 1.14.x API" OFF)
+ if (${EXAMPLE_VARNAME}_USE_114_API AND ${xyapi} GREATER 114)
+ set (${xyapi} "114")
+ endif ()
+
+ #-----------------------------------------------------------------------------
+ # Option to use 1.16.x API
+ #-----------------------------------------------------------------------------
+ option (${EXAMPLE_VARNAME}_USE_116_API "Use the HDF5 1.16.x API" OFF)
+ if (${EXAMPLE_VARNAME}_USE_116_API AND ${xyapi} GREATER 116)
+ set (${xyapi} "116")
+ endif ()
+endmacro ()
diff --git a/HDF5Examples/config/cmake/HDFMacros.cmake b/HDF5Examples/config/cmake/HDFMacros.cmake
new file mode 100644
index 0000000..9ce592d
--- /dev/null
+++ b/HDF5Examples/config/cmake/HDFMacros.cmake
@@ -0,0 +1,209 @@
+#-------------------------------------------------------------------------------
+macro (SET_HDF_BUILD_TYPE)
+ get_property (_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if (_isMultiConfig)
+ # HDF_CFG_BUILD_TYPE is used in the Fortran install commands for the build location of the .mod files
+ set (HDF_CFG_BUILD_TYPE \${CMAKE_INSTALL_CONFIG_NAME})
+ if (CMAKE_BUILD_TYPE)
+ # set the default to the specified command line define
+ set (HDF_CFG_NAME ${CMAKE_BUILD_TYPE})
+ else ()
+ # set the default to the MultiConfig variable
+ set (HDF_CFG_NAME "$<CONFIG>")
+ endif ()
+ else ()
+ set (HDF_CFG_BUILD_TYPE ".")
+ if (CMAKE_BUILD_TYPE)
+ set (HDF_CFG_NAME ${CMAKE_BUILD_TYPE})
+ else ()
+ set (HDF_CFG_NAME "Release")
+ endif ()
+ endif ()
+endmacro ()
+
+#-------------------------------------------------------------------------------
+macro (TARGET_C_PROPERTIES wintarget libtype)
+ target_compile_options(${wintarget} PRIVATE
+ "$<$<C_COMPILER_ID:MSVC>:${WIN_COMPILE_FLAGS}>"
+ "$<$<CXX_COMPILER_ID:MSVC>:${WIN_COMPILE_FLAGS}>"
+ )
+ if(MSVC)
+ set_property(TARGET ${wintarget} APPEND PROPERTY LINK_FLAGS "${WIN_LINK_FLAGS}")
+ endif()
+endmacro ()
+
+macro (HDFTEST_COPY_FILE src dest target)
+ add_custom_command(
+ OUTPUT "${dest}"
+ COMMAND "${CMAKE_COMMAND}"
+ ARGS -E copy_if_different "${src}" "${dest}"
+ DEPENDS "${src}"
+ )
+ list (APPEND ${target}_list "${dest}")
+endmacro ()
+
+macro (HDF_DIR_PATHS package_prefix)
+ option (H5EX_USE_GNU_DIRS "TRUE to use GNU Coding Standard install directory variables, FALSE to use historical settings" FALSE)
+ if (H5EX_USE_GNU_DIRS)
+ include(GNUInstallDirs)
+ if (NOT ${package_prefix}_INSTALL_BIN_DIR)
+ set (${package_prefix}_INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR})
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_LIB_DIR)
+ set (${package_prefix}_INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR})
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_JAR_DIR)
+ set (${package_prefix}_INSTALL_JAR_DIR ${CMAKE_INSTALL_LIBDIR})
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_INCLUDE_DIR)
+ set (${package_prefix}_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR})
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_MODULE_DIR)
+ set (${package_prefix}_INSTALL_MODULE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/mod)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_DATA_DIR)
+ set (${package_prefix}_INSTALL_DATA_DIR ${CMAKE_INSTALL_DATADIR})
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_CMAKE_DIR)
+ set (${package_prefix}_INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_DOC_DIR)
+ set (${package_prefix}_INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR})
+ endif ()
+ message(STATUS "GNU: ${${package_prefix}_INSTALL_DOC_DIR}")
+ endif ()
+
+ if (APPLE)
+ option (${package_prefix}_BUILD_FRAMEWORKS "TRUE to build as frameworks libraries, FALSE to build according to BUILD_SHARED_LIBS" FALSE)
+ endif ()
+
+ if (NOT ${package_prefix}_INSTALL_BIN_DIR)
+ set (${package_prefix}_INSTALL_BIN_DIR bin)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_LIB_DIR)
+ if (APPLE)
+ if (${package_prefix}_BUILD_FRAMEWORKS)
+ set (${package_prefix}_INSTALL_JAR_DIR ../Java)
+ else ()
+ set (${package_prefix}_INSTALL_JAR_DIR lib)
+ endif ()
+ set (${package_prefix}_INSTALL_FMWK_DIR ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
+ else ()
+ set (${package_prefix}_INSTALL_JAR_DIR lib)
+ endif ()
+ set (${package_prefix}_INSTALL_LIB_DIR lib)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_INCLUDE_DIR)
+ set (${package_prefix}_INSTALL_INCLUDE_DIR include)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_MODULE_DIR)
+ set (${package_prefix}_INSTALL_MODULE_DIR mod)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_DATA_DIR)
+ if (NOT MSVC)
+ if (APPLE)
+ if (${package_prefix}_BUILD_FRAMEWORKS)
+ set (${package_prefix}_INSTALL_EXTRA_DIR ../SharedSupport)
+ else ()
+ set (${package_prefix}_INSTALL_EXTRA_DIR share)
+ endif ()
+ set (${package_prefix}_INSTALL_FWRK_DIR ${CMAKE_INSTALL_FRAMEWORK_PREFIX})
+ endif ()
+ set (${package_prefix}_INSTALL_DATA_DIR share)
+ else ()
+ set (${package_prefix}_INSTALL_DATA_DIR ".")
+ endif ()
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_CMAKE_DIR)
+ set (${package_prefix}_INSTALL_CMAKE_DIR cmake)
+ endif ()
+ if (NOT ${package_prefix}_INSTALL_DOC_DIR)
+ set (${package_prefix}_INSTALL_DOC_DIR ${${package_prefix}_INSTALL_DATA_DIR})
+ endif ()
+ message(STATUS "Final: ${${package_prefix}_INSTALL_DOC_DIR}")
+
+ # Always use full RPATH, i.e. don't skip the full RPATH for the build tree
+ set (CMAKE_SKIP_BUILD_RPATH FALSE)
+ # when building, don't use the install RPATH already
+ # (but later on when installing)
+ set (CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
+ # add the automatically determined parts of the RPATH
+ # which point to directories outside the build tree to the install RPATH
+ set (CMAKE_BUILD_WITH_INSTALL_RPATH ON)
+ if (APPLE)
+ set (CMAKE_INSTALL_NAME_DIR "@rpath")
+ set (CMAKE_INSTALL_RPATH
+ "@executable_path/../${${package_prefix}_INSTALL_LIB_DIR}"
+ "@executable_path/"
+ "@loader_path/../${${package_prefix}_INSTALL_LIB_DIR}"
+ "@loader_path/"
+ )
+ else ()
+ set (CMAKE_INSTALL_RPATH "\$ORIGIN/../${${package_prefix}_INSTALL_LIB_DIR}:\$ORIGIN/")
+ endif ()
+
+ if (DEFINED ADDITIONAL_CMAKE_PREFIX_PATH AND EXISTS "${ADDITIONAL_CMAKE_PREFIX_PATH}")
+ set (CMAKE_PREFIX_PATH ${ADDITIONAL_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH})
+ endif ()
+
+ #set the default debug suffix for all library targets
+ if(NOT CMAKE_DEBUG_POSTFIX)
+ if (WIN32)
+ set (CMAKE_DEBUG_POSTFIX "_D")
+ else ()
+ set (CMAKE_DEBUG_POSTFIX "_debug")
+ endif ()
+ endif ()
+
+ SET_HDF_BUILD_TYPE()
+
+#-----------------------------------------------------------------------------
+# Setup output Directories
+#-----------------------------------------------------------------------------
+ if (NOT ${package_prefix}_EXTERNALLY_CONFIGURED)
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Executables."
+ )
+ set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all Libraries"
+ )
+ set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all static libraries."
+ )
+ set (CMAKE_Fortran_MODULE_DIRECTORY
+ ${PROJECT_BINARY_DIR}/mod CACHE PATH "Single Directory for all fortran modules."
+ )
+ get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ if(_isMultiConfig)
+ set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${HDF_CFG_NAME})
+ set (CMAKE_PDB_OUTPUT_DIRECTORY
+ ${PROJECT_BINARY_DIR}/bin CACHE PATH "Single Directory for all pdb files."
+ )
+ else ()
+ set (CMAKE_TEST_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
+ endif ()
+ else ()
+ # if we are externally configured, but the project uses old cmake scripts
+ # this may not be set and utilities like H5detect will fail
+ if (NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
+ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH})
+ endif ()
+ endif ()
+
+ include (FetchContent)
+endmacro ()
+
+macro (ADD_H5_FLAGS h5_flag_var infile)
+ file (STRINGS ${infile} TEST_FLAG_STREAM)
+ list (LENGTH TEST_FLAG_STREAM len_flag)
+ if (len_flag GREATER 0)
+ math (EXPR _FP_LEN "${len_flag} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET TEST_FLAG_STREAM ${line} str_flag)
+ string (REGEX REPLACE "^#.*" "" str_flag "${str_flag}")
+ if (str_flag)
+ list (APPEND ${h5_flag_var} "${str_flag}")
+ endif ()
+ endforeach ()
+ endif ()
+endmacro ()
diff --git a/HDF5Examples/config/cmake/UseJava.cmake b/HDF5Examples/config/cmake/UseJava.cmake
new file mode 100644
index 0000000..2783cb6
--- /dev/null
+++ b/HDF5Examples/config/cmake/UseJava.cmake
@@ -0,0 +1,1654 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+UseJava
+-------
+
+This file provides support for ``Java``. It is assumed that
+:module:`FindJava` has already been loaded. See :module:`FindJava` for
+information on how to load Java into your ``CMake`` project.
+
+Synopsis
+^^^^^^^^
+
+.. parsed-literal::
+
+ `Creating and Installing JARS`_
+ `add_jar`_ (<target_name> [SOURCES] <source1> [<source2>...] ...)
+ `install_jar`_ (<target_name> DESTINATION <destination> [COMPONENT <component>])
+ `install_jni_symlink`_ (<target_name> DESTINATION <destination> [COMPONENT <component>])
+
+ `Header Generation`_
+ `create_javah`_ ((TARGET <target> | GENERATED_FILES <VAR>) CLASSES <class>... ...)
+
+ `Exporting JAR Targets`_
+ `install_jar_exports`_ (TARGETS <jars>... FILE <filename> DESTINATION <destination> ...)
+ `export_jars`_ (TARGETS <jars>... [NAMESPACE <namespace>] FILE <filename>)
+
+ `Finding JARs`_
+ `find_jar`_ (<VAR> NAMES <name1> [<name2>...] [PATHS <path1> [<path2>... ENV <var>]] ...)
+
+ `Creating Java Documentation`_
+ `create_javadoc`_ (<VAR> (PACKAGES <pkg1> [<pkg2>...] | FILES <file1> [<file2>...]) ...)
+
+Creating And Installing JARs
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. _add_jar:
+
+.. command:: add_jar
+
+ Creates a jar file containing java objects and, optionally, resources::
+
+ add_jar(<target_name>
+ [SOURCES] <source1> [<source2>...] [<resource1>...]
+ [INCLUDE_JARS <jar1> [<jar2>...]]
+ [ENTRY_POINT <entry>]
+ [VERSION <version>]
+ [MANIFEST <manifest>]
+ [OUTPUT_NAME <name>]
+ [OUTPUT_DIR <dir>]
+ [GENERATE_NATIVE_HEADERS <target>
+ [DESTINATION (<dir>|INSTALL <dir> [BUILD <dir>])]]
+ )
+
+ This command creates a ``<target_name>.jar``. It compiles the given
+ ``<source>`` files and adds the given ``<resource>`` files to
+ the jar file. Source files can be java files or listing files
+ (prefixed by ``@``). If only resource files are given then just a jar file
+ is created.
+
+ ``SOURCES``
+ Compiles the specified source files and adds the result in the jar file.
+
+ .. versionadded:: 3.4
+ Support for response files, prefixed by ``@``.
+
+ ``INCLUDE_JARS``
+ The list of jars are added to the classpath when compiling the java sources
+ and also to the dependencies of the target. ``INCLUDE_JARS`` also accepts
+ other target names created by ``add_jar()``. For backwards compatibility,
+ jar files listed as sources are ignored (as they have been since the first
+ version of this module).
+
+ ``ENTRY_POINT``
+ Defines an entry point in the jar file.
+
+ ``VERSION``
+ Adds a version to the target output name.
+
+ The following example will create a jar file with the name
+ ``shibboleet-1.2.0.jar`` and will create a symlink ``shibboleet.jar``
+ pointing to the jar with the version information.
+
+ .. code-block:: cmake
+
+ add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
+
+ ``MANIFEST``
+ Defines a custom manifest for the jar.
+
+ ``OUTPUT_NAME``
+ Specify a different output name for the target.
+
+ ``OUTPUT_DIR``
+ Sets the directory where the jar file will be generated. If not specified,
+ :variable:`CMAKE_CURRENT_BINARY_DIR` is used as the output directory.
+
+ ``GENERATE_NATIVE_HEADERS``
+ .. versionadded:: 3.11
+
+ Generates native header files for methods declared as native. These files
+ provide the connective glue that allow your Java and C code to interact.
+ An INTERFACE target will be created for an easy usage of generated files.
+ Sub-option ``DESTINATION`` can be used to specify the output directory for
+ generated header files.
+
+ This option requires, at least, version 1.8 of the JDK.
+
+ For an optimum usage of this option, it is recommended to include module
+ JNI before any call to ``add_jar()``. The produced target for native
+ headers can then be used to compile C/C++ sources with the
+ :command:`target_link_libraries` command.
+
+ .. code-block:: cmake
+
+ find_package(JNI)
+ add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native)
+ add_library(bar bar.cpp)
+ target_link_libraries(bar PRIVATE foo-native)
+
+ .. versionadded:: 3.20
+ ``DESTINATION`` sub-option now supports the possibility to specify
+ different output directories for ``BUILD`` and ``INSTALL`` steps. If
+ ``BUILD`` directory is not specified, a default directory will be used.
+
+ To export the interface target generated by ``GENERATE_NATIVE_HEADERS``
+ option, sub-option ``INSTALL`` of ``DESTINATION`` is required:
+
+ .. code-block:: cmake
+
+ add_jar(foo foo.java GENERATE_NATIVE_HEADERS foo-native
+ DESTINATION INSTALL include)
+ install(TARGETS foo-native EXPORT native)
+ install(DIRECTORY "$<TARGET_PROPERTY:foo-native,NATIVE_HEADERS_DIRECTORY>/"
+ DESTINATION include)
+ install(EXPORT native DESTINATION /to/export NAMESPACE foo)
+
+ Some variables can be set to customize the behavior of ``add_jar()`` as well
+ as the java compiler:
+
+ ``CMAKE_JAVA_COMPILE_FLAGS``
+ Specify additional flags to java compiler.
+
+ ``CMAKE_JAVA_INCLUDE_PATH``
+ Specify additional paths to the class path.
+
+ ``CMAKE_JNI_TARGET``
+ If the target is a JNI library, sets this boolean variable to ``TRUE`` to
+ enable creation of a JNI symbolic link (see also
+ :ref:`install_jni_symlink() <install_jni_symlink>`).
+
+ ``CMAKE_JAR_CLASSES_PREFIX``
+ If multiple jars should be produced from the same java source filetree,
+ to prevent the accumulation of duplicate class files in subsequent jars,
+ set/reset ``CMAKE_JAR_CLASSES_PREFIX`` prior to calling the ``add_jar()``:
+
+ .. code-block:: cmake
+
+ set(CMAKE_JAR_CLASSES_PREFIX com/redhat/foo)
+ add_jar(foo foo.java)
+
+ set(CMAKE_JAR_CLASSES_PREFIX com/redhat/bar)
+ add_jar(bar bar.java)
+
+ The ``add_jar()`` function sets the following target properties on
+ ``<target_name>``:
+
+ ``INSTALL_FILES``
+ The files which should be installed. This is used by
+ :ref:`install_jar() <install_jar>`.
+ ``JNI_SYMLINK``
+ The JNI symlink which should be installed. This is used by
+ :ref:`install_jni_symlink() <install_jni_symlink>`.
+ ``JAR_FILE``
+ The location of the jar file so that you can include it.
+ ``CLASSDIR``
+ The directory where the class files can be found. For example to use them
+ with ``javah``.
+ ``NATIVE_HEADERS_DIRECTORY``
+ .. versionadded:: 3.20
+
+ The directory where native headers are generated. Defined when option
+ ``GENERATE_NATIVE_HEADERS`` is specified.
+
+.. _install_jar:
+
+.. command:: install_jar
+
+ This command installs the jar file to the given destination::
+
+ install_jar(<target_name> <destination>)
+ install_jar(<target_name> DESTINATION <destination> [COMPONENT <component>])
+
+ This command installs the ``<target_name>`` file to the given
+ ``<destination>``. It should be called in the same scope as
+ :ref:`add_jar() <add_jar>` or it will fail.
+
+ .. versionadded:: 3.4
+ The second signature with ``DESTINATION`` and ``COMPONENT`` options.
+
+ ``DESTINATION``
+ Specify the directory on disk to which a file will be installed.
+
+ ``COMPONENT``
+ Specify an installation component name with which the install rule is
+ associated, such as "runtime" or "development".
+
+ The ``install_jar()`` command sets the following target properties
+ on ``<target_name>``:
+
+ ``INSTALL_DESTINATION``
+ Holds the ``<destination>`` as described above, and is used by
+ :ref:`install_jar_exports() <install_jar_exports>`.
+
+.. _install_jni_symlink:
+
+.. command:: install_jni_symlink
+
+ Installs JNI symlinks for target generated by :ref:`add_jar() <add_jar>`::
+
+ install_jni_symlink(<target_name> <destination>)
+ install_jni_symlink(<target_name> DESTINATION <destination> [COMPONENT <component>])
+
+ This command installs the ``<target_name>`` JNI symlinks to the given
+ ``<destination>``. It should be called in the same scope as
+ :ref:`add_jar() <add_jar>` or it will fail.
+
+ .. versionadded:: 3.4
+ The second signature with ``DESTINATION`` and ``COMPONENT`` options.
+
+ ``DESTINATION``
+ Specify the directory on disk to which a file will be installed.
+
+ ``COMPONENT``
+ Specify an installation component name with which the install rule is
+ associated, such as "runtime" or "development".
+
+ Utilize the following commands to create a JNI symbolic link:
+
+ .. code-block:: cmake
+
+ set(CMAKE_JNI_TARGET TRUE)
+ add_jar(shibboleet shibbotleet.java VERSION 1.2.0)
+ install_jar(shibboleet ${LIB_INSTALL_DIR}/shibboleet)
+ install_jni_symlink(shibboleet ${JAVA_LIB_INSTALL_DIR})
+
+Header Generation
+^^^^^^^^^^^^^^^^^
+
+.. _create_javah:
+
+.. command:: create_javah
+
+ .. versionadded:: 3.4
+
+ Generates C header files for java classes::
+
+ create_javah(TARGET <target> | GENERATED_FILES <VAR>
+ CLASSES <class>...
+ [CLASSPATH <classpath>...]
+ [DEPENDS <depend>...]
+ [OUTPUT_NAME <path>|OUTPUT_DIR <path>]
+ )
+
+ .. deprecated:: 3.11
+ This command will no longer be supported starting with version 10 of the JDK
+ due to the `suppression of javah tool <http://openjdk.java.net/jeps/313>`_.
+ The :ref:`add_jar(GENERATE_NATIVE_HEADERS) <add_jar>` command should be
+ used instead.
+
+ Create C header files from java classes. These files provide the connective
+ glue that allow your Java and C code to interact.
+
+ There are two main signatures for ``create_javah()``. The first signature
+ returns generated files through variable specified by the ``GENERATED_FILES``
+ option. For example:
+
+ .. code-block:: cmake
+
+ create_javah(GENERATED_FILES files_headers
+ CLASSES org.cmake.HelloWorld
+ CLASSPATH hello.jar
+ )
+
+ The second signature for ``create_javah()`` creates a target which
+ encapsulates header files generation. E.g.
+
+ .. code-block:: cmake
+
+ create_javah(TARGET target_headers
+ CLASSES org.cmake.HelloWorld
+ CLASSPATH hello.jar
+ )
+
+ Both signatures share same options.
+
+ ``CLASSES``
+ Specifies Java classes used to generate headers.
+
+ ``CLASSPATH``
+ Specifies various paths to look up classes. Here ``.class`` files, jar
+ files or targets created by command add_jar can be used.
+
+ ``DEPENDS``
+ Targets on which the javah target depends.
+
+ ``OUTPUT_NAME``
+ Concatenates the resulting header files for all the classes listed by
+ option ``CLASSES`` into ``<path>``. Same behavior as option ``-o`` of
+ ``javah`` tool.
+
+ ``OUTPUT_DIR``
+ Sets the directory where the header files will be generated. Same behavior
+ as option ``-d`` of ``javah`` tool. If not specified,
+ :variable:`CMAKE_CURRENT_BINARY_DIR` is used as the output directory.
+
+Exporting JAR Targets
+^^^^^^^^^^^^^^^^^^^^^
+
+.. _install_jar_exports:
+
+.. command:: install_jar_exports
+
+ .. versionadded:: 3.7
+
+ Installs a target export file::
+
+ install_jar_exports(TARGETS <jars>...
+ [NAMESPACE <namespace>]
+ FILE <filename>
+ DESTINATION <destination> [COMPONENT <component>])
+
+ This command installs a target export file ``<filename>`` for the named jar
+ targets to the given ``<destination>`` directory. Its function is similar to
+ that of :command:`install(EXPORT)`.
+
+ ``TARGETS``
+ List of targets created by :ref:`add_jar() <add_jar>` command.
+
+ ``NAMESPACE``
+ .. versionadded:: 3.9
+
+ The ``<namespace>`` value will be prepend to the target names as they are
+ written to the import file.
+
+ ``FILE``
+ Specify name of the export file.
+
+
+ ``DESTINATION``
+ Specify the directory on disk to which a file will be installed.
+
+ ``COMPONENT``
+ Specify an installation component name with which the install rule is
+ associated, such as "runtime" or "development".
+
+.. _export_jars:
+
+.. command:: export_jars
+
+ .. versionadded:: 3.7
+
+ Writes a target export file::
+
+ export_jars(TARGETS <jars>...
+ [NAMESPACE <namespace>]
+ FILE <filename>)
+
+ This command writes a target export file ``<filename>`` for the named ``<jars>``
+ targets. Its function is similar to that of :command:`export`.
+
+ ``TARGETS``
+ List of targets created by :ref:`add_jar() <add_jar>` command.
+
+ ``NAMESPACE``
+ .. versionadded:: 3.9
+
+ The ``<namespace>`` value will be prepend to the target names as they are
+ written to the import file.
+
+ ``FILE``
+ Specify name of the export file.
+
+Finding JARs
+^^^^^^^^^^^^
+
+.. _find_jar:
+
+.. command:: find_jar
+
+ Finds the specified jar file::
+
+ find_jar(<VAR>
+ <name> | NAMES <name1> [<name2>...]
+ [PATHS <path1> [<path2>... ENV <var>]]
+ [VERSIONS <version1> [<version2>]]
+ [DOC "cache documentation string"]
+ )
+
+ This command is used to find a full path to the named jar. A cache
+ entry named by ``<VAR>`` is created to store the result of this command.
+ If the full path to a jar is found the result is stored in the
+ variable and the search will not repeated unless the variable is
+ cleared. If nothing is found, the result will be ``<VAR>-NOTFOUND``, and
+ the search will be attempted again next time ``find_jar()`` is invoked with
+ the same variable.
+
+ ``NAMES``
+ Specify one or more possible names for the jar file.
+
+ ``PATHS``
+ Specify directories to search in addition to the default locations.
+ The ``ENV`` var sub-option reads paths from a system environment variable.
+
+ ``VERSIONS``
+ Specify jar versions.
+
+ ``DOC``
+ Specify the documentation string for the ``<VAR>`` cache entry.
+
+Creating Java Documentation
+^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. _create_javadoc:
+
+.. command:: create_javadoc
+
+ Creates java documentation based on files and packages::
+
+ create_javadoc(<VAR>
+ (PACKAGES <pkg1> [<pkg2>...] | FILES <file1> [<file2>...])
+ [SOURCEPATH <sourcepath>]
+ [CLASSPATH <classpath>]
+ [INSTALLPATH <install path>]
+ [DOCTITLE <the documentation title>]
+ [WINDOWTITLE <the title of the document>]
+ [AUTHOR (TRUE|FALSE)]
+ [USE (TRUE|FALSE)]
+ [VERSION (TRUE|FALSE)]
+ )
+
+ The ``create_javadoc()`` command can be used to create java documentation.
+ There are two main signatures for ``create_javadoc()``.
+
+ The first signature works with package names on a path with source files:
+
+ .. code-block:: cmake
+
+ create_javadoc(my_example_doc
+ PACKAGES com.example.foo com.example.bar
+ SOURCEPATH "${CMAKE_CURRENT_SOURCE_DIR}"
+ CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
+ WINDOWTITLE "My example"
+ DOCTITLE "<h1>My example</h1>"
+ AUTHOR TRUE
+ USE TRUE
+ VERSION TRUE
+ )
+
+ The second signature for ``create_javadoc()`` works on a given list of files:
+
+ .. code-block:: cmake
+
+ create_javadoc(my_example_doc
+ FILES java/A.java java/B.java
+ CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH}
+ WINDOWTITLE "My example"
+ DOCTITLE "<h1>My example</h1>"
+ AUTHOR TRUE
+ USE TRUE
+ VERSION TRUE
+ )
+
+ Both signatures share most of the options. For more details please read the
+ javadoc manpage.
+
+ ``PACKAGES``
+ Specify java packages.
+
+ ``FILES``
+ Specify java source files. If relative paths are specified, they are
+ relative to :variable:`CMAKE_CURRENT_SOURCE_DIR`.
+
+ ``SOURCEPATH``
+ Specify the directory where to look for packages. By default,
+ :variable:`CMAKE_CURRENT_SOURCE_DIR` directory is used.
+
+ ``CLASSPATH``
+ Specify where to find user class files. Same behavior as option
+ ``-classpath`` of ``javadoc`` tool.
+
+ ``INSTALLPATH``
+ Specify where to install the java documentation. If you specified, the
+ documentation will be installed to
+ ``${CMAKE_INSTALL_PREFIX}/share/javadoc/<VAR>``.
+
+ ``DOCTITLE``
+ Specify the title to place near the top of the overview summary file.
+ Same behavior as option ``-doctitle`` of ``javadoc`` tool.
+
+ ``WINDOWTITLE``
+ Specify the title to be placed in the HTML ``<title>`` tag. Same behavior
+ as option ``-windowtitle`` of ``javadoc`` tool.
+
+ ``AUTHOR``
+ When value ``TRUE`` is specified, includes the ``@author`` text in the
+ generated docs. Same behavior as option ``-author`` of ``javadoc`` tool.
+
+ ``USE``
+ When value ``TRUE`` is specified, creates class and package usage pages.
+ Includes one Use page for each documented class and package. Same behavior
+ as option ``-use`` of ``javadoc`` tool.
+
+ ``VERSION``
+ When value ``TRUE`` is specified, includes the version text in the
+ generated docs. Same behavior as option ``-version`` of ``javadoc`` tool.
+#]=======================================================================]
+
+include(CMakeParseArguments)
+
+function (__java_copy_file src dest comment)
+ add_custom_command(
+ OUTPUT ${dest}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ARGS ${src}
+ ${dest}
+ DEPENDS ${src}
+ COMMENT ${comment}
+ )
+endfunction ()
+
+function(__java_lcat VAR)
+ foreach(_line IN LISTS ARGN)
+ string(APPEND ${VAR} "${_line}\n")
+ endforeach()
+
+ set(${VAR} "${${VAR}}" PARENT_SCOPE)
+endfunction()
+
+function(__java_export_jar VAR TARGET PATH)
+ get_target_property(_jarpath ${TARGET} JAR_FILE)
+ get_filename_component(_jarname ${_jarpath} NAME)
+ set(_target "${_jar_NAMESPACE}${TARGET}")
+ __java_lcat(${VAR}
+ "# Create imported target ${_target}"
+ "add_library(${_target} IMPORTED STATIC)"
+ "set_target_properties(${_target} PROPERTIES"
+ " IMPORTED_LOCATION \"${PATH}/${_jarname}\""
+ " JAR_FILE \"${PATH}/${_jarname}\")"
+ ""
+ )
+ set(${VAR} "${${VAR}}" PARENT_SCOPE)
+endfunction()
+
+# define helper scripts
+set(_JAVA_EXPORT_TARGETS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/javaTargets.cmake.in)
+set(_JAVA_CLASS_FILELIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaClassFilelist.cmake)
+set(_JAVA_SYMLINK_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/UseJavaSymlinks.cmake)
+
+if (CMAKE_HOST_WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
+ set(_UseJava_PATH_SEP "$<SEMICOLON>")
+else ()
+ set(_UseJava_PATH_SEP ":")
+endif()
+
+function(add_jar _TARGET_NAME)
+
+ cmake_parse_arguments(_add_jar
+ ""
+ "VERSION;OUTPUT_DIR;OUTPUT_NAME;ENTRY_POINT;MANIFEST"
+ "SOURCES;INCLUDE_JARS;GENERATE_NATIVE_HEADERS"
+ ${ARGN}
+ )
+
+ # In CMake < 2.8.12, add_jar used variables which were set prior to calling
+ # add_jar for customizing the behavior of add_jar. In order to be backwards
+ # compatible, check if any of those variables are set, and use them to
+ # initialize values of the named arguments. (Giving the corresponding named
+ # argument will override the value set here.)
+ #
+ # New features should use named arguments only.
+ if(NOT DEFINED _add_jar_VERSION AND DEFINED CMAKE_JAVA_TARGET_VERSION)
+ set(_add_jar_VERSION "${CMAKE_JAVA_TARGET_VERSION}")
+ endif()
+ if(NOT DEFINED _add_jar_OUTPUT_DIR AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR)
+ set(_add_jar_OUTPUT_DIR "${CMAKE_JAVA_TARGET_OUTPUT_DIR}")
+ endif()
+ if(NOT DEFINED _add_jar_OUTPUT_NAME AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_NAME)
+ set(_add_jar_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}")
+ # reset
+ set(CMAKE_JAVA_TARGET_OUTPUT_NAME)
+ endif()
+ if(NOT DEFINED _add_jar_ENTRY_POINT AND DEFINED CMAKE_JAVA_JAR_ENTRY_POINT)
+ set(_add_jar_ENTRY_POINT "${CMAKE_JAVA_JAR_ENTRY_POINT}")
+ endif()
+
+ # This *should* still work if <resources1>... are included without a
+ # named RESOURCES argument. In that case, the old behavior of potentially
+ # misplacing the within the Jar will behave as previously (incorrectly)
+ set(_JAVA_SOURCE_FILES ${_add_jar_SOURCES} ${_add_jar_UNPARSED_ARGUMENTS})
+
+ if (NOT DEFINED _add_jar_OUTPUT_DIR)
+ set(_add_jar_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
+ else()
+ get_filename_component(_add_jar_OUTPUT_DIR ${_add_jar_OUTPUT_DIR} ABSOLUTE)
+ endif()
+ # ensure output directory exists
+ file (MAKE_DIRECTORY "${_add_jar_OUTPUT_DIR}")
+
+ if (_add_jar_ENTRY_POINT)
+ set(_ENTRY_POINT_OPTION e)
+ set(_ENTRY_POINT_VALUE ${_add_jar_ENTRY_POINT})
+ endif ()
+
+ if (_add_jar_MANIFEST)
+ set(_MANIFEST_OPTION m)
+ get_filename_component (_MANIFEST_VALUE "${_add_jar_MANIFEST}" ABSOLUTE)
+ endif ()
+
+ unset (_GENERATE_NATIVE_HEADERS)
+ if (_add_jar_GENERATE_NATIVE_HEADERS)
+ # Raise an error if JDK version is less than 1.8 because javac -h is not supported
+ # by earlier versions.
+ if (Java_VERSION VERSION_LESS 1.8)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS is not supported with this version of Java.")
+ endif()
+
+ unset (_GENERATE_NATIVE_HEADERS_OUTPUT_DESC)
+
+ cmake_parse_arguments (_add_jar_GENERATE_NATIVE_HEADERS "" "" "DESTINATION" ${_add_jar_GENERATE_NATIVE_HEADERS})
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: missing required argument.")
+ endif()
+ list (LENGTH _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS length)
+ if (length GREATER 1)
+ list (REMOVE_AT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS 0)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS}: unexpected argument(s).")
+ endif()
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION)
+ set (_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir/native_headers")
+ else()
+ list (LENGTH _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION length)
+ if (NOT length EQUAL 1)
+ cmake_parse_arguments (_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "" "BUILD;INSTALL" "" "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION}")
+ if (_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_UNPARSED_ARGUMENTS)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: DESTINATION: ${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_UNPARSED_ARGUMENTS}: unexpected argument(s).")
+ endif()
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_INSTALL)
+ message (FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: DESTINATION: INSTALL sub-option is required.")
+ endif()
+ if (NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_BUILD)
+ set(_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_BUILD "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir/native_headers")
+ endif()
+ set(_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_BUILD}")
+ set(_GENERATE_NATIVE_HEADERS_OUTPUT_DESC "$<BUILD_INTERFACE:${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_BUILD}>" "$<INSTALL_INTERFACE:${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION_INSTALL}>")
+ endif()
+ endif()
+
+ set (_GENERATE_NATIVE_HEADERS_TARGET ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS})
+ set (_GENERATE_NATIVE_HEADERS_OUTPUT_DIR "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION}")
+ set (_GENERATE_NATIVE_HEADERS -h "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ if(NOT _GENERATE_NATIVE_HEADERS_OUTPUT_DESC)
+ set(_GENERATE_NATIVE_HEADERS_OUTPUT_DESC "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ endif()
+ endif()
+
+ if (LIBRARY_OUTPUT_PATH)
+ set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH})
+ else ()
+ set(CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${_add_jar_OUTPUT_DIR})
+ endif ()
+
+ set(CMAKE_JAVA_INCLUDE_PATH
+ ${CMAKE_JAVA_INCLUDE_PATH}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_JAVA_OBJECT_OUTPUT_PATH}
+ ${CMAKE_JAVA_LIBRARY_OUTPUT_PATH}
+ )
+
+ foreach (JAVA_INCLUDE_DIR IN LISTS CMAKE_JAVA_INCLUDE_PATH)
+ string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${_UseJava_PATH_SEP}${JAVA_INCLUDE_DIR}")
+ endforeach()
+
+ set(CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir")
+
+ set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar")
+ if (_add_jar_OUTPUT_NAME AND _add_jar_VERSION)
+ set(_JAVA_TARGET_OUTPUT_NAME "${_add_jar_OUTPUT_NAME}-${_add_jar_VERSION}.jar")
+ set(_JAVA_TARGET_OUTPUT_LINK "${_add_jar_OUTPUT_NAME}.jar")
+ elseif (_add_jar_VERSION)
+ set(_JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${_add_jar_VERSION}.jar")
+ set(_JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar")
+ elseif (_add_jar_OUTPUT_NAME)
+ set(_JAVA_TARGET_OUTPUT_NAME "${_add_jar_OUTPUT_NAME}.jar")
+ endif ()
+
+ set(_JAVA_CLASS_FILES)
+ set(_JAVA_COMPILE_FILES)
+ set(_JAVA_COMPILE_FILELISTS)
+ set(_JAVA_DEPENDS)
+ set(_JAVA_COMPILE_DEPENDS)
+ set(_JAVA_RESOURCE_FILES)
+ set(_JAVA_RESOURCE_FILES_RELATIVE)
+ foreach(_JAVA_SOURCE_FILE IN LISTS _JAVA_SOURCE_FILES)
+ get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
+ get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
+ get_filename_component(_JAVA_PATH ${_JAVA_SOURCE_FILE} PATH)
+ get_filename_component(_JAVA_FULL ${_JAVA_SOURCE_FILE} ABSOLUTE)
+
+ if (_JAVA_SOURCE_FILE MATCHES "^@(.+)$")
+ get_filename_component(_JAVA_FULL ${CMAKE_MATCH_1} ABSOLUTE)
+ list(APPEND _JAVA_COMPILE_FILELISTS ${_JAVA_FULL})
+
+ elseif (_JAVA_EXT MATCHES ".java")
+ file(RELATIVE_PATH _JAVA_REL_BINARY_PATH ${CMAKE_CURRENT_BINARY_DIR} ${_JAVA_FULL})
+ file(RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${_JAVA_FULL})
+ string(LENGTH ${_JAVA_REL_BINARY_PATH} _BIN_LEN)
+ string(LENGTH ${_JAVA_REL_SOURCE_PATH} _SRC_LEN)
+ if (_BIN_LEN LESS _SRC_LEN)
+ set(_JAVA_REL_PATH ${_JAVA_REL_BINARY_PATH})
+ else ()
+ set(_JAVA_REL_PATH ${_JAVA_REL_SOURCE_PATH})
+ endif ()
+ get_filename_component(_JAVA_REL_PATH ${_JAVA_REL_PATH} PATH)
+
+ list(APPEND _JAVA_COMPILE_FILES ${_JAVA_SOURCE_FILE})
+ set(_JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class")
+ set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES} ${_JAVA_CLASS_FILE})
+
+ elseif (_JAVA_EXT MATCHES ".jar"
+ OR _JAVA_EXT MATCHES ".war"
+ OR _JAVA_EXT MATCHES ".ear"
+ OR _JAVA_EXT MATCHES ".sar")
+ # Ignored for backward compatibility
+
+ elseif (_JAVA_EXT STREQUAL "")
+ list(APPEND CMAKE_JAVA_INCLUDE_PATH ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}} ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}_CLASSPATH})
+ list(APPEND _JAVA_DEPENDS ${JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE}})
+
+ else ()
+ __java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
+ ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
+ "Copying ${_JAVA_SOURCE_FILE} to the build directory")
+ list(APPEND _JAVA_RESOURCE_FILES ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE})
+ list(APPEND _JAVA_RESOURCE_FILES_RELATIVE ${_JAVA_SOURCE_FILE})
+ endif ()
+ endforeach()
+
+ foreach(_JAVA_INCLUDE_JAR IN LISTS _add_jar_INCLUDE_JARS)
+ if (TARGET ${_JAVA_INCLUDE_JAR})
+ get_target_property(_JAVA_JAR_PATH ${_JAVA_INCLUDE_JAR} JAR_FILE)
+ if (_JAVA_JAR_PATH)
+ string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${_UseJava_PATH_SEP}${_JAVA_JAR_PATH}")
+ list(APPEND CMAKE_JAVA_INCLUDE_PATH ${_JAVA_JAR_PATH})
+ list(APPEND _JAVA_DEPENDS ${_JAVA_INCLUDE_JAR})
+ list(APPEND _JAVA_COMPILE_DEPENDS ${_JAVA_JAR_PATH})
+ else ()
+ message(SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar")
+ endif ()
+ else ()
+ string(APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${_UseJava_PATH_SEP}${_JAVA_INCLUDE_JAR}")
+ list(APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}")
+ list(APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}")
+ list(APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}")
+ endif ()
+ endforeach()
+
+ if (_JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS)
+ set (_JAVA_SOURCES_FILELISTS)
+
+ if (_JAVA_COMPILE_FILES)
+ # Create the list of files to compile.
+ set(_JAVA_SOURCES_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_sources)
+ string(REPLACE ";" "\"\n\"" _JAVA_COMPILE_STRING "\"${_JAVA_COMPILE_FILES}\"")
+ file(WRITE ${_JAVA_SOURCES_FILE} ${_JAVA_COMPILE_STRING})
+ list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_SOURCES_FILE}")
+ endif()
+ if (_JAVA_COMPILE_FILELISTS)
+ foreach (_JAVA_FILELIST IN LISTS _JAVA_COMPILE_FILELISTS)
+ list (APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_FILELIST}")
+ endforeach()
+ endif()
+
+ # Compile the java files and create a list of class files
+ add_custom_command(
+ # NOTE: this command generates an artificial dependency file
+ OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
+ COMMAND ${Java_JAVAC_EXECUTABLE}
+ ${CMAKE_JAVA_COMPILE_FLAGS}
+ -classpath "${CMAKE_JAVA_INCLUDE_PATH_FINAL}"
+ -d ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ ${_GENERATE_NATIVE_HEADERS}
+ ${_JAVA_SOURCES_FILELISTS}
+ COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
+ DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
+ )
+ add_custom_command(
+ OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
+ COMMAND ${CMAKE_COMMAND}
+ -DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ -DCMAKE_JAR_CLASSES_PREFIX=${CMAKE_JAR_CLASSES_PREFIX}
+ -P ${_JAVA_CLASS_FILELIST_SCRIPT}
+ DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+ else ()
+ # create an empty java_class_filelist
+ if (NOT EXISTS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist)
+ file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist "")
+ endif()
+ endif ()
+
+ # create the jar file
+ set(_JAVA_JAR_OUTPUT_PATH
+ "${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_NAME}")
+ if (CMAKE_JNI_TARGET)
+ add_custom_command(
+ OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
+ COMMAND ${Java_JAR_EXECUTABLE}
+ -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
+ ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
+ COMMAND ${CMAKE_COMMAND}
+ -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
+ -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
+ -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
+ -P ${_JAVA_SYMLINK_SCRIPT}
+ COMMAND ${CMAKE_COMMAND}
+ -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
+ -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_JAR_OUTPUT_PATH}
+ -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
+ -P ${_JAVA_SYMLINK_SCRIPT}
+ DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
+ WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
+ )
+ else ()
+ add_custom_command(
+ OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
+ COMMAND ${Java_JAR_EXECUTABLE}
+ -cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
+ ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
+ COMMAND ${CMAKE_COMMAND}
+ -D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
+ -D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
+ -D_JAVA_TARGET_OUTPUT_LINK=${_JAVA_TARGET_OUTPUT_LINK}
+ -P ${_JAVA_SYMLINK_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
+ COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
+ )
+ endif ()
+
+ # Add the target and make sure we have the latest resource files.
+ add_custom_target(${_TARGET_NAME} ALL DEPENDS ${_JAVA_JAR_OUTPUT_PATH})
+
+ set_property(
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ INSTALL_FILES
+ ${_JAVA_JAR_OUTPUT_PATH}
+ )
+
+ if (_JAVA_TARGET_OUTPUT_LINK)
+ set_property(
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ INSTALL_FILES
+ ${_JAVA_JAR_OUTPUT_PATH}
+ ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
+ )
+
+ if (CMAKE_JNI_TARGET)
+ set_property(
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ JNI_SYMLINK
+ ${_add_jar_OUTPUT_DIR}/${_JAVA_TARGET_OUTPUT_LINK}
+ )
+ endif ()
+ endif ()
+
+ set_property(
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ JAR_FILE
+ ${_JAVA_JAR_OUTPUT_PATH}
+ )
+
+ set_property(
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ CLASSDIR
+ ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ )
+
+ if (_GENERATE_NATIVE_HEADERS)
+ # create an INTERFACE library encapsulating include directory for generated headers
+ add_library (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE)
+ target_include_directories (${_GENERATE_NATIVE_HEADERS_TARGET} INTERFACE
+ "${_GENERATE_NATIVE_HEADERS_OUTPUT_DESC}"
+ ${JNI_INCLUDE_DIRS})
+ set_property(TARGET ${_GENERATE_NATIVE_HEADERS_TARGET} PROPERTY NATIVE_HEADERS_DIRECTORY "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ # this INTERFACE library depends on jar generation
+ add_dependencies (${_GENERATE_NATIVE_HEADERS_TARGET} ${_TARGET_NAME})
+
+ set_property (DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
+ "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}")
+ endif()
+endfunction()
+
+function(INSTALL_JAR _TARGET_NAME)
+ if (ARGC EQUAL 2)
+ set (_DESTINATION ${ARGV1})
+ else()
+ cmake_parse_arguments(_install_jar
+ ""
+ "DESTINATION;COMPONENT"
+ ""
+ ${ARGN})
+ if (_install_jar_DESTINATION)
+ set (_DESTINATION ${_install_jar_DESTINATION})
+ else()
+ message(SEND_ERROR "install_jar: ${_TARGET_NAME}: DESTINATION must be specified.")
+ endif()
+
+ if (_install_jar_COMPONENT)
+ set (_COMPONENT COMPONENT ${_install_jar_COMPONENT})
+ endif()
+ endif()
+
+ get_property(__FILES
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ INSTALL_FILES
+ )
+ set_property(
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ INSTALL_DESTINATION
+ ${_DESTINATION}
+ )
+
+ if (__FILES)
+ install(
+ FILES
+ ${__FILES}
+ DESTINATION
+ ${_DESTINATION}
+ ${_COMPONENT}
+ )
+ else ()
+ message(SEND_ERROR "install_jar: The target ${_TARGET_NAME} is not known in this scope.")
+ endif ()
+endfunction()
+
+function(INSTALL_JNI_SYMLINK _TARGET_NAME)
+ if (ARGC EQUAL 2)
+ set (_DESTINATION ${ARGV1})
+ else()
+ cmake_parse_arguments(_install_jni_symlink
+ ""
+ "DESTINATION;COMPONENT"
+ ""
+ ${ARGN})
+ if (_install_jni_symlink_DESTINATION)
+ set (_DESTINATION ${_install_jni_symlink_DESTINATION})
+ else()
+ message(SEND_ERROR "install_jni_symlink: ${_TARGET_NAME}: DESTINATION must be specified.")
+ endif()
+
+ if (_install_jni_symlink_COMPONENT)
+ set (_COMPONENT COMPONENT ${_install_jni_symlink_COMPONENT})
+ endif()
+ endif()
+
+ get_property(__SYMLINK
+ TARGET
+ ${_TARGET_NAME}
+ PROPERTY
+ JNI_SYMLINK
+ )
+
+ if (__SYMLINK)
+ install(
+ FILES
+ ${__SYMLINK}
+ DESTINATION
+ ${_DESTINATION}
+ ${_COMPONENT}
+ )
+ else ()
+ message(SEND_ERROR "install_jni_symlink: The target ${_TARGET_NAME} is not known in this scope.")
+ endif ()
+endfunction()
+
+function (find_jar VARIABLE)
+ set(_jar_names)
+ set(_jar_files)
+ set(_jar_versions)
+ set(_jar_paths
+ /usr/share/java/
+ /usr/local/share/java/
+ ${Java_JAR_PATHS})
+ set(_jar_doc "NOTSET")
+
+ set(_state "name")
+
+ foreach (arg IN LISTS ARGN)
+ if (_state STREQUAL "name")
+ if (arg STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (arg STREQUAL "NAMES")
+ set(_state "names")
+ elseif (arg STREQUAL "PATHS")
+ set(_state "paths")
+ elseif (arg STREQUAL "DOC")
+ set(_state "doc")
+ else ()
+ set(_jar_names ${arg})
+ if (_jar_doc STREQUAL "NOTSET")
+ set(_jar_doc "Finding ${arg} jar")
+ endif ()
+ endif ()
+ elseif (_state STREQUAL "versions")
+ if (arg STREQUAL "NAMES")
+ set(_state "names")
+ elseif (arg STREQUAL "PATHS")
+ set(_state "paths")
+ elseif (arg STREQUAL "DOC")
+ set(_state "doc")
+ else ()
+ set(_jar_versions ${_jar_versions} ${arg})
+ endif ()
+ elseif (_state STREQUAL "names")
+ if (arg STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (arg STREQUAL "PATHS")
+ set(_state "paths")
+ elseif (arg STREQUAL "DOC")
+ set(_state "doc")
+ else ()
+ set(_jar_names ${_jar_names} ${arg})
+ if (_jar_doc STREQUAL "NOTSET")
+ set(_jar_doc "Finding ${arg} jar")
+ endif ()
+ endif ()
+ elseif (_state STREQUAL "paths")
+ if (arg STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (arg STREQUAL "NAMES")
+ set(_state "names")
+ elseif (arg STREQUAL "DOC")
+ set(_state "doc")
+ else ()
+ set(_jar_paths ${_jar_paths} ${arg})
+ endif ()
+ elseif (_state STREQUAL "doc")
+ if (arg STREQUAL "VERSIONS")
+ set(_state "versions")
+ elseif (arg STREQUAL "NAMES")
+ set(_state "names")
+ elseif (arg STREQUAL "PATHS")
+ set(_state "paths")
+ else ()
+ set(_jar_doc ${arg})
+ endif ()
+ endif ()
+ endforeach ()
+
+ if (NOT _jar_names)
+ message(FATAL_ERROR "find_jar: No name to search for given")
+ endif ()
+
+ foreach (jar_name IN LISTS _jar_names)
+ foreach (version IN LISTS _jar_versions)
+ set(_jar_files ${_jar_files} ${jar_name}-${version}.jar)
+ endforeach ()
+ set(_jar_files ${_jar_files} ${jar_name}.jar)
+ endforeach ()
+
+ find_file(${VARIABLE}
+ NAMES ${_jar_files}
+ PATHS ${_jar_paths}
+ DOC ${_jar_doc}
+ NO_DEFAULT_PATH)
+endfunction ()
+
+function(create_javadoc _target)
+ set(_javadoc_packages)
+ set(_javadoc_files)
+ set(_javadoc_overview)
+ set(_javadoc_sourcepath)
+ set(_javadoc_classpath)
+ set(_javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc")
+ set(_javadoc_doctitle)
+ set(_javadoc_windowtitle)
+ set(_javadoc_author FALSE)
+ set(_javadoc_version FALSE)
+ set(_javadoc_use FALSE)
+
+ set(_state "package")
+
+ foreach (arg IN LISTS ARGN)
+ if (_state STREQUAL "package")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_packages ${arg})
+ set(_state "packages")
+ endif ()
+ elseif (_state STREQUAL "packages")
+ if (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ list(APPEND _javadoc_packages ${arg})
+ endif ()
+ elseif (_state STREQUAL "files")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ list(APPEND _javadoc_files ${arg})
+ endif ()
+ elseif (_state STREQUAL "sourcepath")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ list(APPEND _javadoc_sourcepath ${arg})
+ endif ()
+ elseif (_state STREQUAL "classpath")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ list(APPEND _javadoc_classpath ${arg})
+ endif ()
+ elseif (_state STREQUAL "installpath")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_installpath ${arg})
+ endif ()
+ elseif (_state STREQUAL "doctitle")
+ if (${arg} STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_doctitle ${arg})
+ endif ()
+ elseif (_state STREQUAL "windowtitle")
+ if (${arg} STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_windowtitle ${arg})
+ endif ()
+ elseif (_state STREQUAL "author")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_author ${arg})
+ endif ()
+ elseif (_state STREQUAL "use")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_use ${arg})
+ endif ()
+ elseif (_state STREQUAL "version")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "OVERVIEW")
+ set(_state "overview")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_version ${arg})
+ endif ()
+ elseif (_state STREQUAL "overview")
+ if (arg STREQUAL "PACKAGES")
+ set(_state "packages")
+ elseif (arg STREQUAL "FILES")
+ set(_state "files")
+ elseif (arg STREQUAL "SOURCEPATH")
+ set(_state "sourcepath")
+ elseif (arg STREQUAL "CLASSPATH")
+ set(_state "classpath")
+ elseif (arg STREQUAL "INSTALLPATH")
+ set(_state "installpath")
+ elseif (arg STREQUAL "DOCTITLE")
+ set(_state "doctitle")
+ elseif (arg STREQUAL "WINDOWTITLE")
+ set(_state "windowtitle")
+ elseif (arg STREQUAL "AUTHOR")
+ set(_state "author")
+ elseif (arg STREQUAL "USE")
+ set(_state "use")
+ elseif (arg STREQUAL "VERSION")
+ set(_state "version")
+ else ()
+ set(_javadoc_overview ${arg})
+ endif ()
+ endif ()
+ endforeach ()
+
+ set(_javadoc_builddir ${CMAKE_CURRENT_BINARY_DIR}/javadoc/${_target})
+ set(_javadoc_options -d ${_javadoc_builddir})
+
+ if (_javadoc_sourcepath)
+ list(JOIN _javadoc_sourcepath "${_UseJava_PATH_SEP}" _javadoc_sourcepath)
+ list(APPEND _javadoc_options -sourcepath "\"${_javadoc_sourcepath}\"")
+ endif ()
+
+ if (_javadoc_overview)
+ list(JOIN _javadoc_overview "${_UseJava_PATH_SEP}" _javadoc_overview)
+ list(APPEND _javadoc_options -overview "\"${_javadoc_overview}\"")
+ endif ()
+
+ if (_javadoc_classpath)
+ list(JOIN _javadoc_classpath "${_UseJava_PATH_SEP}" _javadoc_classpath)
+ list(APPEND _javadoc_options -classpath "\"${_javadoc_classpath}\"")
+ endif ()
+
+ if (_javadoc_doctitle)
+ list(APPEND _javadoc_options -doctitle '${_javadoc_doctitle}')
+ endif ()
+
+ if (_javadoc_windowtitle)
+ list(APPEND _javadoc_options -windowtitle '${_javadoc_windowtitle}')
+ endif ()
+
+ if (_javadoc_author)
+ list(APPEND _javadoc_options -author)
+ endif ()
+
+ if (_javadoc_use)
+ list(APPEND _javadoc_options -use)
+ endif ()
+
+ if (_javadoc_version)
+ list(APPEND _javadoc_options -version)
+ endif ()
+
+ add_custom_target(${_target}_javadoc ALL
+ COMMAND ${Java_JAVADOC_EXECUTABLE}
+ -Xdoclint:none
+ ${_javadoc_options}
+ ${_javadoc_files}
+ ${_javadoc_packages}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ )
+
+ install(
+ DIRECTORY ${_javadoc_builddir}
+ DESTINATION ${_javadoc_installpath}
+ )
+endfunction()
+
+function (create_javah)
+ if (Java_VERSION VERSION_GREATER_EQUAL 10)
+ message (FATAL_ERROR "create_javah: not supported with this Java version. Use add_jar(GENERATE_NATIVE_HEADERS) instead.")
+ elseif (Java_VERSION VERSION_GREATER_EQUAL 1.8)
+ message (DEPRECATION "create_javah: this command will no longer be supported starting with version 10 of JDK. Update your project by using command add_jar(GENERATE_NATIVE_HEADERS) instead.")
+ endif()
+
+ cmake_parse_arguments(_create_javah
+ ""
+ "TARGET;GENERATED_FILES;OUTPUT_NAME;OUTPUT_DIR"
+ "CLASSES;CLASSPATH;DEPENDS"
+ ${ARGN})
+
+ # check parameters
+ if (NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES)
+ message (FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified.")
+ endif()
+ if (_create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR)
+ message (FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive.")
+ endif()
+
+ if (NOT _create_javah_CLASSES)
+ message (FATAL_ERROR "create_javah: CLASSES is a required parameter.")
+ endif()
+
+ set (_output_files)
+
+ # handle javah options
+ set (_javah_options)
+
+ if (_create_javah_CLASSPATH)
+ # CLASSPATH can specify directories, jar files or targets created with add_jar command
+ set (_classpath)
+ foreach (_path IN LISTS _create_javah_CLASSPATH)
+ if (TARGET ${_path})
+ get_target_property (_jar_path ${_path} JAR_FILE)
+ if (_jar_path)
+ list (APPEND _classpath "${_jar_path}")
+ list (APPEND _create_javah_DEPENDS "${_path}")
+ else()
+ message(SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar.")
+ endif()
+ elseif (EXISTS "${_path}")
+ list (APPEND _classpath "${_path}")
+ if (NOT IS_DIRECTORY "${_path}")
+ list (APPEND _create_javah_DEPENDS "${_path}")
+ endif()
+ else()
+ message(SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist.")
+ endif()
+ endforeach()
+ string (REPLACE ";" "${_UseJava_PATH_SEP}" _classpath "${_classpath}")
+ list (APPEND _javah_options -classpath "${_classpath}")
+ endif()
+
+ if (_create_javah_OUTPUT_DIR)
+ list (APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}")
+ endif()
+
+ if (_create_javah_OUTPUT_NAME)
+ list (APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}")
+ set (_output_files "${_create_javah_OUTPUT_NAME}")
+
+ get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY)
+ get_filename_component (_create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE)
+ endif()
+
+ if (NOT _create_javah_OUTPUT_DIR)
+ set (_create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+
+ if (NOT _create_javah_OUTPUT_NAME)
+ # compute output names
+ foreach (_class IN LISTS _create_javah_CLASSES)
+ string (REPLACE "." "_" _c_header "${_class}")
+ set (_c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h")
+ list (APPEND _output_files "${_c_header}")
+ endforeach()
+ endif()
+
+ # finalize custom command arguments
+ if (_create_javah_DEPENDS)
+ list (INSERT _create_javah_DEPENDS 0 DEPENDS)
+ endif()
+
+ add_custom_command (OUTPUT ${_output_files}
+ COMMAND "${Java_JAVAH_EXECUTABLE}" ${_javah_options} -jni ${_create_javah_CLASSES}
+ ${_create_javah_DEPENDS}
+ WORKING_DIRECTORY ${_create_javah_OUTPUT_DIR}
+ COMMENT "Building C header files from classes...")
+
+ if (_create_javah_TARGET)
+ add_custom_target (${_create_javah_TARGET} ALL DEPENDS ${_output_files})
+ endif()
+ if (_create_javah_GENERATED_FILES)
+ set (${_create_javah_GENERATED_FILES} ${_output_files} PARENT_SCOPE)
+ endif()
+endfunction()
+
+function(export_jars)
+ # Parse and validate arguments
+ cmake_parse_arguments(_export_jars
+ ""
+ "FILE;NAMESPACE"
+ "TARGETS"
+ ${ARGN}
+ )
+ if (NOT _export_jars_FILE)
+ message(SEND_ERROR "export_jars: FILE must be specified.")
+ endif()
+ if (NOT _export_jars_TARGETS)
+ message(SEND_ERROR "export_jars: TARGETS must be specified.")
+ endif()
+ set(_jar_NAMESPACE "${_export_jars_NAMESPACE}")
+
+ # Set content of generated exports file
+ string(REPLACE ";" " " __targets__ "${_export_jars_TARGETS}")
+ set(__targetdefs__ "")
+ foreach(_target IN LISTS _export_jars_TARGETS)
+ get_target_property(_jarpath ${_target} JAR_FILE)
+ get_filename_component(_jarpath ${_jarpath} PATH)
+ __java_export_jar(__targetdefs__ ${_target} "${_jarpath}")
+ endforeach()
+
+ # Generate exports file
+ configure_file(
+ ${_JAVA_EXPORT_TARGETS_SCRIPT}
+ ${_export_jars_FILE}
+ @ONLY
+ )
+endfunction()
+
+function(install_jar_exports)
+ # Parse and validate arguments
+ cmake_parse_arguments(_install_jar_exports
+ ""
+ "FILE;DESTINATION;COMPONENT;NAMESPACE"
+ "TARGETS"
+ ${ARGN}
+ )
+ if (NOT _install_jar_exports_FILE)
+ message(SEND_ERROR "install_jar_exports: FILE must be specified.")
+ endif()
+ if (NOT _install_jar_exports_DESTINATION)
+ message(SEND_ERROR "install_jar_exports: DESTINATION must be specified.")
+ endif()
+ if (NOT _install_jar_exports_TARGETS)
+ message(SEND_ERROR "install_jar_exports: TARGETS must be specified.")
+ endif()
+ set(_jar_NAMESPACE "${_install_jar_exports_NAMESPACE}")
+
+ if (_install_jar_exports_COMPONENT)
+ set (_COMPONENT COMPONENT ${_install_jar_exports_COMPONENT})
+ endif()
+
+ # Determine relative path from installed export file to install prefix
+ if(IS_ABSOLUTE "${_install_jar_exports_DESTINATION}")
+ file(RELATIVE_PATH _relpath
+ ${_install_jar_exports_DESTINATION}
+ ${CMAKE_INSTALL_PREFIX}
+ )
+ else()
+ file(RELATIVE_PATH _relpath
+ ${CMAKE_INSTALL_PREFIX}/${_install_jar_exports_DESTINATION}
+ ${CMAKE_INSTALL_PREFIX}
+ )
+ endif()
+
+ # Set up unique location for generated exports file
+ string(SHA256 _hash "${_install_jar_exports_DESTINATION}")
+ set(_tmpdir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/JavaExports/${_hash})
+
+ # Set content of generated exports file
+ string(REPLACE ";" " " __targets__ "${_install_jar_exports_TARGETS}")
+ set(__targetdefs__ "set(_prefix \${CMAKE_CURRENT_LIST_DIR}/${_relpath})\n\n")
+ foreach(_target IN LISTS _install_jar_exports_TARGETS)
+ get_target_property(_dir ${_target} INSTALL_DESTINATION)
+ __java_export_jar(__targetdefs__ ${_target} "\${_prefix}/${_dir}")
+ endforeach()
+ __java_lcat(__targetdefs__ "\nunset(_prefix)")
+
+ # Generate and install exports file
+ configure_file(
+ ${_JAVA_EXPORT_TARGETS_SCRIPT}
+ ${_tmpdir}/${_install_jar_exports_FILE}
+ @ONLY
+ )
+ install(FILES ${_tmpdir}/${_install_jar_exports_FILE}
+ DESTINATION ${_install_jar_exports_DESTINATION}
+ ${_COMPONENT})
+endfunction()
diff --git a/HDF5Examples/config/cmake/UseJavaClassFilelist.cmake b/HDF5Examples/config/cmake/UseJavaClassFilelist.cmake
new file mode 100644
index 0000000..d90ca48
--- /dev/null
+++ b/HDF5Examples/config/cmake/UseJavaClassFilelist.cmake
@@ -0,0 +1,39 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details.
+
+# This script creates a list of compiled Java class files to be added to
+# a jar file. This avoids including cmake files which get created in
+# the binary directory.
+
+if (CMAKE_JAVA_CLASS_OUTPUT_PATH)
+ if (EXISTS "${CMAKE_JAVA_CLASS_OUTPUT_PATH}")
+
+ set(_JAVA_GLOBBED_FILES)
+ if (CMAKE_JAR_CLASSES_PREFIX)
+ foreach(JAR_CLASS_PREFIX ${CMAKE_JAR_CLASSES_PREFIX})
+ message(STATUS "JAR_CLASS_PREFIX: ${JAR_CLASS_PREFIX}")
+
+ file(GLOB_RECURSE _JAVA_GLOBBED_TMP_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${JAR_CLASS_PREFIX}/*.class")
+ if (_JAVA_GLOBBED_TMP_FILES)
+ list(APPEND _JAVA_GLOBBED_FILES ${_JAVA_GLOBBED_TMP_FILES})
+ endif ()
+ endforeach()
+ else()
+ file(GLOB_RECURSE _JAVA_GLOBBED_FILES "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/*.class")
+ endif ()
+
+ set(_JAVA_CLASS_FILES)
+ # file(GLOB_RECURSE foo RELATIVE) is broken so we need this.
+ foreach(_JAVA_GLOBBED_FILE ${_JAVA_GLOBBED_FILES})
+ file(RELATIVE_PATH _JAVA_CLASS_FILE ${CMAKE_JAVA_CLASS_OUTPUT_PATH} ${_JAVA_GLOBBED_FILE})
+ set(_JAVA_CLASS_FILES ${_JAVA_CLASS_FILES}${_JAVA_CLASS_FILE}\n)
+ endforeach()
+
+ # write to file
+ file(WRITE ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist ${_JAVA_CLASS_FILES})
+
+ else ()
+ message(SEND_ERROR "FATAL: Java class output path doesn't exist")
+ endif ()
+else ()
+ message(SEND_ERROR "FATAL: Can't find CMAKE_JAVA_CLASS_OUTPUT_PATH")
+endif ()
diff --git a/HDF5Examples/config/cmake/UseJavaSymlinks.cmake b/HDF5Examples/config/cmake/UseJavaSymlinks.cmake
new file mode 100644
index 0000000..183a744
--- /dev/null
+++ b/HDF5Examples/config/cmake/UseJavaSymlinks.cmake
@@ -0,0 +1,16 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See https://cmake.org/licensing for details.
+
+# Helper script for UseJava.cmake
+
+if (UNIX AND _JAVA_TARGET_OUTPUT_LINK)
+ if (_JAVA_TARGET_OUTPUT_NAME)
+ find_program(LN_EXECUTABLE NAMES ln)
+
+ execute_process(
+ COMMAND ${LN_EXECUTABLE} -sf "${_JAVA_TARGET_OUTPUT_NAME}" "${_JAVA_TARGET_OUTPUT_LINK}"
+ WORKING_DIRECTORY ${_JAVA_TARGET_DIR}
+ )
+ else ()
+ message(SEND_ERROR "FATAL: Can't find _JAVA_TARGET_OUTPUT_NAME")
+ endif ()
+endif ()
diff --git a/HDF5Examples/config/cmake/cacheinit.cmake b/HDF5Examples/config/cmake/cacheinit.cmake
new file mode 100644
index 0000000..3e5a8eb
--- /dev/null
+++ b/HDF5Examples/config/cmake/cacheinit.cmake
@@ -0,0 +1,27 @@
+# This is the CMakeCache file.
+
+########################
+# EXTERNAL cache entries
+########################
+
+set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE)
+
+set (H5EX_BUILD_TESTING ON CACHE BOOL "Build HDF5 Unit Testing" FORCE)
+
+#set (HDF_ENABLE_PARALLEL ON CACHE BOOL "Enable parallel build (requires MPI)" FORCE)
+
+#set (HDF_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE)
+
+#set (HDF_BUILD_FILTERS ON CACHE BOOL "Build filter support" FORCE)
+
+#set (HDF_ENABLE_F2003 ON CACHE BOOL "Enable FORTRAN 2003 Standard" FORCE)
+
+#set (HDF_ENABLE_THREADSAFE ON CACHE BOOL "Enable Threadsafety" FORCE)
+
+#set (HDF_BUILD_JAVA ON CACHE BOOL "Build JAVA support" FORCE)
+
+set (HDF5_PACKAGE_NAME "hdf5" CACHE STRING "Name of HDF5 package" FORCE)
+
+set (HDF5_NAMESPACE "hdf5::" CACHE STRING "Name space of HDF5 library" FORCE)
+
+set (CPACK_PACKAGE_VERSION "2.0.4" CACHE STRING "Version of HDF5 examples source package" FORCE)
diff --git a/HDF5Examples/config/cmake/grepTest.cmake b/HDF5Examples/config/cmake/grepTest.cmake
new file mode 100644
index 0000000..2ec8387
--- /dev/null
+++ b/HDF5Examples/config/cmake/grepTest.cmake
@@ -0,0 +1,213 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# grepTest.cmake executes a command and captures the output in a file. File is then compared
+# against a reference file. Exit status of command can also be compared.
+
+# arguments checking
+if (NOT TEST_PROGRAM)
+ message (FATAL_ERROR "Require TEST_PROGRAM to be defined")
+endif ()
+if (NOT TEST_FOLDER)
+ message (FATAL_ERROR "Require TEST_FOLDER to be defined")
+endif ()
+if (NOT TEST_OUTPUT)
+ message (FATAL_ERROR "Require TEST_OUTPUT to be defined")
+endif ()
+if (NOT TEST_FILTER)
+ message (STATUS "Optional TEST_FILTER to be defined")
+endif ()
+if (NOT TEST_REFERENCE)
+ message (FATAL_ERROR "Require TEST_REFERENCE to be defined")
+endif ()
+
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+endif ()
+
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+endif ()
+
+message (STATUS "COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}")
+
+if (TEST_LIBRARY_DIRECTORY)
+ if (WIN32)
+ set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}")
+ elseif (APPLE)
+ set (ENV{DYLD_LIBRARY_PATH} "$ENV{DYLD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
+ else ()
+ set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
+ endif ()
+endif ()
+
+if (TEST_ENV_VAR)
+ set (ENV{${TEST_ENV_VAR}} "${TEST_ENV_VALUE}")
+ message (TRACE "ENV:${TEST_ENV_VAR}=$ENV{${TEST_ENV_VAR}}")
+endif ()
+
+# run the test program, capture the stdout/stderr and the result var
+execute_process (
+ COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}
+ WORKING_DIRECTORY ${TEST_FOLDER}
+ RESULT_VARIABLE TEST_RESULT
+ OUTPUT_FILE ${TEST_OUTPUT}
+ ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_OUT
+ ERROR_VARIABLE TEST_ERROR
+)
+
+message (STATUS "COMMAND Result: ${TEST_RESULT}")
+
+message (STATUS "COMMAND Error: ${TEST_ERROR}")
+
+# remove special output
+file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+string (FIND TEST_STREAM "_pmi_alps" TEST_FIND_RESULT)
+if (TEST_FIND_RESULT GREATER -1)
+ string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}")
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_STREAM})
+endif ()
+
+# if the TEST_ERRREF exists grep the error output with the error reference
+set (TEST_ERRREF_RESULT 0)
+if (TEST_ERRREF)
+ # if the .err file exists grep the error output with the error reference before comparing stdout
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_ERR_STREAM)
+ list (LENGTH TEST_ERR_STREAM test_len)
+ if (test_len GREATER 0)
+ # TEST_ERRREF should always be matched
+ string (REGEX MATCH "${TEST_ERRREF}" TEST_MATCH ${TEST_ERR_STREAM})
+ string (COMPARE EQUAL "${TEST_ERRREF}" "${TEST_MATCH}" TEST_ERRREF_RESULT)
+ if (NOT TEST_ERRREF_RESULT)
+ message (FATAL_ERROR "Failed: The error output of ${TEST_PROGRAM} did not contain ${TEST_ERRREF}")
+ endif ()
+ endif ()
+ endif ()
+
+ #always compare output file to reference unless this must be skipped
+ set (TEST_COMPARE_RESULT 0)
+ if (NOT TEST_SKIP_COMPARE)
+ if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}")
+ file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ if (WIN32)
+ configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF)
+ if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp")
+ file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE})
+ endif ()
+ #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM)
+ #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}")
+ endif ()
+ if (NOT TEST_SORT_COMPARE)
+ # now compare the output with the reference
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE}
+ RESULT_VARIABLE TEST_COMPARE_RESULT
+ )
+ else ()
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2)
+ list (SORT v1)
+ list (SORT v2)
+ if (NOT v1 STREQUAL v2)
+ set(TEST_COMPARE_RESULT 1)
+ endif ()
+ endif ()
+
+ if (TEST_COMPARE_RESULT)
+ set (TEST_COMPARE_RESULT 0)
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act)
+ list (LENGTH test_act len_act)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref)
+ list (LENGTH test_ref len_ref)
+ if (len_act GREATER 0 AND len_ref GREATER 0)
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET test_act ${line} str_act)
+ list (GET test_ref ${line} str_ref)
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
+ set (TEST_COMPARE_RESULT 1)
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ endif ()
+ endif ()
+ endforeach ()
+ else ()
+ if (len_act EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty")
+ endif ()
+ if (len_ref EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty")
+ endif ()
+ endif ()
+ if (NOT len_act EQUAL len_ref)
+ set (TEST_COMPARE_RESULT 1)
+ endif ()
+ endif ()
+ endif ()
+
+ message (STATUS "COMPARE Result: ${TEST_COMPARE_RESULT}")
+
+ # again, if return value is !=0 scream and shout
+ if (TEST_COMPARE_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}")
+ endif ()
+ endif ()
+ endif ()
+else ()
+ # else grep the output with the reference
+ set (TEST_GREP_RESULT 0)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ # TEST_REFERENCE should always be matched
+ string (REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM})
+ string (COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_GREP_RESULT)
+ if (NOT TEST_GREP_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}")
+ endif ()
+ endif ()
+endif ()
+
+
+if (TEST_FILTER)
+ string (REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM})
+ if (TEST_EXPECT)
+ # TEST_EXPECT (1) interprets TEST_FILTER as; NOT to match
+ string (LENGTH "${TEST_MATCH}" TEST_GREP_RESULT)
+ if (TEST_GREP_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}")
+ endif ()
+ endif ()
+endif ()
+
+if (NOT DEFINED ENV{HDF5_NOCLEANUP})
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+ endif ()
+
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+ endif ()
+
+ if (TEST_DELETE_LIST)
+ foreach (dfile in ${TEST_DELETE_LIST})
+ file (REMOVE ${dfile})
+ endforeach ()
+ endif ()
+endif ()
+
+# everything went fine...
+message (STATUS "Passed: The output of ${TEST_PROGRAM} matched")
+
diff --git a/HDF5Examples/config/cmake/jrunTest.cmake b/HDF5Examples/config/cmake/jrunTest.cmake
new file mode 100644
index 0000000..2d91ee2
--- /dev/null
+++ b/HDF5Examples/config/cmake/jrunTest.cmake
@@ -0,0 +1,305 @@
+# jrunTest.cmake executes a command and captures the output in a file. File is then compared
+# against a reference file. Exit status of command can also be compared.
+cmake_policy(SET CMP0007 NEW)
+
+# arguments checking
+if (NOT TEST_TESTER)
+ message (FATAL_ERROR "Require TEST_TESTER to be defined")
+endif ()
+if (NOT TEST_PROGRAM)
+ message (FATAL_ERROR "Require TEST_PROGRAM to be defined")
+endif ()
+if (NOT TEST_LIBRARY_DIRECTORY)
+ message (STATUS "Require TEST_LIBRARY_DIRECTORY to be defined")
+endif ()
+if (NOT TEST_FOLDER)
+ message (FATAL_ERROR "Require TEST_FOLDER to be defined")
+endif ()
+if (NOT TEST_OUTPUT)
+ message (FATAL_ERROR "Require TEST_OUTPUT to be defined")
+endif ()
+if (NOT TEST_CLASSPATH)
+ message (STATUS "Require TEST_CLASSPATH to be defined")
+endif ()
+
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+endif ()
+
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+endif ()
+
+if (NOT TEST_LOG_LEVEL)
+ set (LOG_LEVEL "info")
+else ()
+ set (LOG_LEVEL "${TEST_LOG_LEVEL}")
+endif ()
+
+message (STATUS "COMMAND: ${TEST_TESTER} -Xmx1024M -Djava.library.path=\"${TEST_LIBRARY_DIRECTORY}\" -cp \"${TEST_CLASSPATH}\" ${TEST_ARGS} ${TEST_PROGRAM} ${ARGN}")
+
+if (WIN32)
+ set (ENV{PATH} "$ENV{PATH}\\;${TEST_LIBRARY_DIRECTORY}")
+elseif (APPLE)
+ set (ENV{DYLD_LIBRARY_PATH} "$ENV{DYLD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
+else ()
+ set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
+endif ()
+
+# run the test program, capture the stdout/stderr and the result var
+execute_process (
+ COMMAND ${TEST_TESTER} -Xmx1024M
+ -Dorg.slf4j.simpleLogger.defaultLogLevel=${LOG_LEVEL}
+ -Djava.library.path=${TEST_LIBRARY_DIRECTORY}
+ -cp "${TEST_CLASSPATH}" ${TEST_ARGS} ${TEST_PROGRAM}
+ ${ARGN}
+ WORKING_DIRECTORY ${TEST_FOLDER}
+ RESULT_VARIABLE TEST_RESULT
+ OUTPUT_FILE ${TEST_OUTPUT}
+ ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_OUT
+ ERROR_VARIABLE TEST_ERROR
+)
+
+message (STATUS "COMMAND Result: ${TEST_RESULT}")
+
+# if the .err file exists and ERRROR_APPEND is enabled
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ if (TEST_MASK_FILE)
+ STRING(REGEX REPLACE "CurrentDir is [^\n]+\n" "CurrentDir is (dir name)\n" TEST_STREAM "${TEST_STREAM}")
+ endif ()
+
+ if (NOT ERROR_APPEND)
+ # write back to original .err file
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}")
+ else ()
+ # append error output to the stdout output file
+ file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+ endif ()
+ endif ()
+endif ()
+
+# if the output file or the .err file needs to mask out error stack info
+if (TEST_MASK_ERROR)
+ if (NOT TEST_ERRREF)
+ # the error stack has been appended to the output file
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ else ()
+ # the error stack remains in the .err file
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+ endif ()
+ string (REGEX REPLACE "Time:[^\n]+\n" "Time: XXXX\n" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}")
+ #string (REGEX REPLACE "v[1-9]*[.][0-9]*[.]" "version (number)." TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "HDF5 .[1-9]*[.][0-9]*[.][0-9]*[^)]*" "HDF5 (version (number)" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "H5Eget_auto[1-2]*" "H5Eget_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "H5Eset_auto[1-2]*" "H5Eset_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}")
+ # write back the changes to the original files
+ if (NOT TEST_ERRREF)
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+ else ()
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}")
+ endif ()
+endif ()
+
+# if the return value is !=expected bail out
+if (NOT TEST_RESULT EQUAL TEST_EXPECT)
+ message (STATUS "ERROR OUTPUT: ${TEST_STREAM}")
+ message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != 0.\n${TEST_ERROR}")
+endif ()
+
+message (STATUS "COMMAND Error: ${TEST_ERROR}")
+
+# compare output files to references unless this must be skipped
+set (TEST_COMPARE_RESULT 0)
+if (NOT TEST_SKIP_COMPARE)
+ if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}")
+ file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ if (WIN32)
+ configure_file(${TEST_FOLDER}/${TEST_REFERENCE} ${TEST_FOLDER}/${TEST_REFERENCE}.tmp NEWLINE_STYLE CRLF)
+ if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}.tmp")
+ file(RENAME ${TEST_FOLDER}/${TEST_REFERENCE}.tmp ${TEST_FOLDER}/${TEST_REFERENCE})
+ endif ()
+ #file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM)
+ #file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}")
+ endif ()
+
+ if (NOT TEST_SORT_COMPARE)
+ # now compare the output with the reference
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE}
+ RESULT_VARIABLE TEST_COMPARE_RESULT
+ )
+ else ()
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2)
+ list (SORT v1)
+ list (SORT v2)
+ if (NOT v1 STREQUAL v2)
+ set(TEST_COMPARE_RESULT 1)
+ endif ()
+ endif ()
+
+ if (TEST_COMPARE_RESULT)
+ set (TEST_COMPARE_RESULT 0)
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act)
+ list (LENGTH test_act len_act)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref)
+ list (LENGTH test_ref len_ref)
+ if (len_act GREATER 0 AND len_ref GREATER 0)
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET test_act ${line} str_act)
+ list (GET test_ref ${line} str_ref)
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
+ set (TEST_COMPARE_RESULT 1)
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ endif ()
+ endif ()
+ endforeach ()
+ else ()
+ if (len_act EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty")
+ endif ()
+ if (len_ref EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty")
+ endif ()
+ endif ()
+ if (NOT len_act EQUAL len_ref)
+ set (TEST_COMPARE_RESULT 1)
+ endif ()
+ endif ()
+ endif ()
+
+ message (STATUS "COMPARE Result: ${TEST_COMPARE_RESULT}")
+
+ # again, if return value is !=0 scream and shout
+ if (TEST_COMPARE_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}")
+ endif ()
+ endif ()
+
+ # now compare the .err file with the error reference, if supplied
+ set (TEST_ERRREF_RESULT 0)
+ if (TEST_ERRREF)
+ file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ if (WIN32)
+ configure_file(${TEST_FOLDER}/${TEST_ERRREF} ${TEST_FOLDER}/${TEST_ERRREF}.tmp NEWLINE_STYLE CRLF)
+ if (EXISTS "${TEST_FOLDER}/${TEST_ERRREF}.tmp")
+ file(RENAME ${TEST_FOLDER}/${TEST_ERRREF}.tmp ${TEST_FOLDER}/${TEST_ERRREF})
+ endif ()
+ #file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM)
+ #file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}")
+ endif ()
+
+ # now compare the error output with the error reference
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${TEST_FOLDER}/${TEST_OUTPUT}.err ${TEST_FOLDER}/${TEST_ERRREF}
+ RESULT_VARIABLE TEST_ERRREF_RESULT
+ )
+ if (TEST_ERRREF_RESULT)
+ set (TEST_ERRREF_RESULT 0)
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT}.err test_act)
+ list (LENGTH test_act len_act)
+ file (STRINGS ${TEST_FOLDER}/${TEST_ERRREF} test_ref)
+ list (LENGTH test_ref len_ref)
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ if (len_act GREATER 0 AND len_ref GREATER 0)
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET test_act ${line} str_act)
+ list (GET test_ref ${line} str_ref)
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
+ set (TEST_ERRREF_RESULT 1)
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ endif ()
+ endif ()
+ endforeach ()
+ else ()
+ if (len_act EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT}.err is empty")
+ endif ()
+ if (len_ref EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_ERRREF} is empty")
+ endif ()
+ endif ()
+ if (NOT len_act EQUAL len_ref)
+ set (TEST_ERRREF_RESULT 1)
+ endif ()
+ endif ()
+ endif ()
+
+ message (STATUS "COMPARE Result: ${TEST_ERRREF_RESULT}")
+
+ # again, if return value is !=0 scream and shout
+ if (TEST_ERRREF_RESULT)
+ message (FATAL_ERROR "Failed: The error output of ${TEST_OUTPUT}.err did not match ${TEST_ERRREF}")
+ endif ()
+ endif ()
+endif ()
+
+set (TEST_GREP_RESULT 0)
+if (TEST_GREP_COMPARE)
+ # now grep the output with the reference
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ # TEST_REFERENCE should always be matched
+ string (REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM})
+ string (COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_GREP_RESULT)
+ if (NOT TEST_GREP_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}")
+ endif ()
+
+ string (REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM})
+ if (TEST_EXPECT)
+ # TEST_EXPECT (1) interprets TEST_FILTER as; NOT to match
+ string (LENGTH "${TEST_MATCH}" TEST_GREP_RESULT)
+ if (TEST_GREP_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}")
+ endif ()
+ endif ()
+ endif ()
+endif ()
+
+# dump the output unless nodisplay option is set
+if (TEST_SKIP_COMPARE AND NOT TEST_NO_DISPLAY)
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E echo ${TEST_STREAM}
+ RESULT_VARIABLE TEST_RESULT
+ )
+ endif ()
+endif ()
+
+if (NOT DEFINED ENV{HDF5_NOCLEANUP})
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+ endif ()
+
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+ endif ()
+
+ if (TEST_DELETE_LIST)
+ foreach (dfile in ${TEST_DELETE_LIST})
+ file (REMOVE ${dfile})
+ endforeach ()
+ endif ()
+endif ()
+
+# everything went fine...
+message (STATUS "${TEST_PROGRAM} Passed")
+
diff --git a/HDF5Examples/config/cmake/runTest.cmake b/HDF5Examples/config/cmake/runTest.cmake
new file mode 100644
index 0000000..d21765a
--- /dev/null
+++ b/HDF5Examples/config/cmake/runTest.cmake
@@ -0,0 +1,387 @@
+#
+# Copyright by The HDF Group.
+# All rights reserved.
+#
+# This file is part of HDF5. The full HDF5 copyright notice, including
+# terms governing use, modification, and redistribution, is contained in
+# the COPYING file, which can be found at the root of the source code
+# distribution tree, or in https://www.hdfgroup.org/licenses.
+# If you do not have access to either file, you may request a copy from
+# help@hdfgroup.org.
+#
+# runTest.cmake executes a command and captures the output in a file. File is then compared
+# against a reference file. Exit status of command can also be compared.
+cmake_policy(SET CMP0007 NEW)
+
+# arguments checking
+if (NOT TEST_PROGRAM)
+ message (FATAL_ERROR "Require TEST_PROGRAM to be defined")
+endif ()
+if (NOT TEST_FOLDER)
+ message (FATAL_ERROR "Require TEST_FOLDER to be defined")
+endif ()
+if (NOT TEST_OUTPUT)
+ message (FATAL_ERROR "Require TEST_OUTPUT to be defined")
+endif ()
+if (NOT TEST_EXPECT)
+ message (STATUS "Require TEST_EXPECT to be defined")
+endif ()
+
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+endif ()
+
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+endif ()
+
+message (STATUS "COMMAND: ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}")
+
+if (TEST_LIBRARY_DIRECTORY)
+ if (WIN32)
+ set (ENV{PATH} "$ENV{PATH};${TEST_LIBRARY_DIRECTORY}")
+ elseif (APPLE)
+ set (ENV{DYLD_LIBRARY_PATH} "$ENV{DYLD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
+ else ()
+ set (ENV{LD_LIBRARY_PATH} "$ENV{LD_LIBRARY_PATH}:${TEST_LIBRARY_DIRECTORY}")
+ endif ()
+endif ()
+
+if (TEST_ENV_VAR)
+ set (ENV{${TEST_ENV_VAR}} "${TEST_ENV_VALUE}")
+ #message (STATUS "ENV:${TEST_ENV_VAR}=$ENV{${TEST_ENV_VAR}}")
+endif ()
+
+if (NOT TEST_INPUT)
+ # run the test program, capture the stdout/stderr and the result var
+ execute_process (
+ COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}
+ WORKING_DIRECTORY ${TEST_FOLDER}
+ RESULT_VARIABLE TEST_RESULT
+ OUTPUT_FILE ${TEST_OUTPUT}
+ ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_OUT
+ ERROR_VARIABLE TEST_ERROR
+ )
+else ()
+ # run the test program with stdin, capture the stdout/stderr and the result var
+ execute_process (
+ COMMAND ${TEST_EMULATOR} ${TEST_PROGRAM} ${TEST_ARGS}
+ WORKING_DIRECTORY ${TEST_FOLDER}
+ RESULT_VARIABLE TEST_RESULT
+ INPUT_FILE ${TEST_INPUT}
+ OUTPUT_FILE ${TEST_OUTPUT}
+ ERROR_FILE ${TEST_OUTPUT}.err
+ OUTPUT_VARIABLE TEST_OUT
+ ERROR_VARIABLE TEST_ERROR
+ )
+endif ()
+
+if (TEST_REGEX)
+ # TEST_REGEX should always be matched
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ string (REGEX MATCH "${TEST_REGEX}" REGEX_MATCH ${TEST_STREAM})
+ string (COMPARE EQUAL "${REGEX_MATCH}" "${TEST_MATCH}" REGEX_RESULT)
+ if (NOT REGEX_RESULT)
+ message (STATUS "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_MATCH}")
+ endif ()
+endif ()
+
+message (STATUS "COMMAND Result: ${TEST_RESULT}")
+
+# if the .err file exists and ERRROR_APPEND is enabled
+if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ if (TEST_MASK_FILE)
+ STRING(REGEX REPLACE "CurrentDir is [^\n]+\n" "CurrentDir is (dir name)\n" TEST_STREAM "${TEST_STREAM}")
+ endif ()
+ # remove special output
+ string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}")
+
+ if (NOT ERROR_APPEND)
+ # write back to original .err file
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}")
+ else ()
+ # append error output to the stdout output file
+ file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+ endif ()
+ endif ()
+endif ()
+
+# append the test result status with a predefined text
+if (TEST_APPEND)
+ file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_APPEND} ${TEST_RESULT}\n")
+endif ()
+
+# if the return value is !=${TEST_EXPECT} bail out
+if (NOT TEST_RESULT EQUAL TEST_EXPECT)
+ if (NOT TEST_NOERRDISPLAY)
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}")
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ message (STATUS "Output :\n${TEST_STREAM}")
+ endif ()
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+ message (STATUS "Error Output :\n${TEST_STREAM}")
+ endif ()
+ endif ()
+ message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}")
+endif ()
+
+message (STATUS "COMMAND Error: ${TEST_ERROR}")
+
+# remove special output
+file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+string (FIND TEST_STREAM "_pmi_alps" TEST_FIND_RESULT)
+if (TEST_FIND_RESULT GREATER -1)
+ string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}")
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_STREAM})
+endif ()
+
+# remove special error output
+if (NOT TEST_ERRREF)
+ # the error stack has been appended to the output file
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+else ()
+ # the error stack remains in the .err file
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+endif ()
+string (FIND TEST_STREAM "no version information available" TEST_FIND_RESULT)
+if (TEST_FIND_RESULT GREATER -1)
+ string (REGEX REPLACE "^.*no version information available[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}")
+ # write back the changes to the original files
+ if (NOT TEST_ERRREF)
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+ else ()
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}")
+ endif ()
+endif ()
+
+# if the output file needs Storage text removed
+if (TEST_MASK)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ string (REGEX REPLACE "Storage:[^\n]+\n" "Storage: <details removed for portability>\n" TEST_STREAM "${TEST_STREAM}")
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+endif ()
+
+# if the output file needs Modified text removed
+if (TEST_MASK_MOD)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ string (REGEX REPLACE "Modified:[^\n]+\n" "Modified: XXXX-XX-XX XX:XX:XX XXX\n" TEST_STREAM "${TEST_STREAM}")
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+endif ()
+
+# if the output file or the .err file needs to mask out error stack info
+if (TEST_MASK_ERROR)
+ if (NOT TEST_ERRREF)
+ # the error stack has been appended to the output file
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ else ()
+ # the error stack remains in the .err file
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM)
+ endif ()
+ string (REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "v[1-9]*[.][0-9]*[.]" "version (number)." TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "[1-9]*[.][0-9]*[.][0-9]*[^)]*" "version (number)" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "H5Eget_auto[1-2]*" "H5Eget_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}")
+ string (REGEX REPLACE "H5Eset_auto[1-2]*" "H5Eset_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}")
+ # write back the changes to the original files
+ if (NOT TEST_ERRREF)
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+ else ()
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}")
+ endif ()
+endif ()
+
+# remove text from the output file
+if (TEST_FILTER)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ string (REGEX REPLACE "${TEST_FILTER}" "${TEST_FILTER_REPLACE}" TEST_STREAM "${TEST_STREAM}")
+ file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}")
+endif ()
+
+if (TEST_REF_FILTER)
+ #message (STATUS "TEST_REF_FILTER: ${TEST_APPEND}${TEST_REF_FILTER}")
+ file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM)
+ string (REGEX REPLACE "${TEST_REF_APPEND}" "${TEST_REF_FILTER}" TEST_STREAM "${TEST_STREAM}")
+ file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}")
+endif ()
+
+# compare output files to references unless this must be skipped
+set (TEST_COMPARE_RESULT 0)
+if (NOT TEST_SKIP_COMPARE)
+ if (EXISTS "${TEST_FOLDER}/${TEST_REFERENCE}")
+ file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+
+ if (NOT TEST_SORT_COMPARE)
+ # now compare the output with the reference
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE}
+ RESULT_VARIABLE TEST_COMPARE_RESULT
+ )
+ else ()
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2)
+ list (SORT v1)
+ list (SORT v2)
+ if (NOT v1 STREQUAL v2)
+ set (TEST_COMPARE_RESULT 1)
+ endif ()
+ endif ()
+
+ if (TEST_COMPARE_RESULT)
+ set (TEST_COMPARE_RESULT 0)
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act)
+ list (LENGTH test_act len_act)
+ file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref)
+ list (LENGTH test_ref len_ref)
+ if (NOT len_act EQUAL len_ref)
+ set (TEST_COMPARE_RESULT 1)
+ endif ()
+ if (len_act GREATER 0 AND len_ref GREATER 0)
+ if (TEST_SORT_COMPARE)
+ list (SORT test_act)
+ list (SORT test_ref)
+ endif ()
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET test_act ${line} str_act)
+ list (GET test_ref ${line} str_ref)
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
+ set (TEST_COMPARE_RESULT 1)
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ endif ()
+ endif ()
+ endforeach ()
+ else ()
+ if (len_act EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty")
+ endif ()
+ if (len_ref EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty")
+ endif ()
+ endif ()
+ endif ()
+ endif ()
+
+ message (STATUS "COMPARE Result: ${TEST_COMPARE_RESULT}")
+
+ # again, if return value is !=0 scream and shout
+ if (TEST_COMPARE_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}")
+ endif ()
+ endif ()
+
+ # now compare the .err file with the error reference, if supplied
+ set (TEST_ERRREF_RESULT 0)
+ if (TEST_ERRREF)
+ file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+
+ # now compare the error output with the error reference
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E compare_files --ignore-eol ${TEST_FOLDER}/${TEST_OUTPUT}.err ${TEST_FOLDER}/${TEST_ERRREF}
+ RESULT_VARIABLE TEST_ERRREF_RESULT
+ )
+ if (TEST_ERRREF_RESULT)
+ set (TEST_ERRREF_RESULT 0)
+ file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT}.err test_act)
+ list (LENGTH test_act len_act)
+ file (STRINGS ${TEST_FOLDER}/${TEST_ERRREF} test_ref)
+ list (LENGTH test_ref len_ref)
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ if (len_act GREATER 0 AND len_ref GREATER 0)
+ math (EXPR _FP_LEN "${len_ref} - 1")
+ foreach (line RANGE 0 ${_FP_LEN})
+ list (GET test_act ${line} str_act)
+ list (GET test_ref ${line} str_ref)
+ if (NOT str_act STREQUAL str_ref)
+ if (str_act)
+ set (TEST_ERRREF_RESULT 1)
+ message (STATUS "line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n")
+ endif ()
+ endif ()
+ endforeach ()
+ else ()
+ if (len_act EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT}.err is empty")
+ endif ()
+ if (len_ref EQUAL 0)
+ message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_ERRREF} is empty")
+ endif ()
+ endif ()
+ if (NOT len_act EQUAL len_ref)
+ set (TEST_ERRREF_RESULT 1)
+ endif ()
+ endif ()
+ endif ()
+
+ message (STATUS "COMPARE Result: ${TEST_ERRREF_RESULT}")
+
+ # again, if return value is !=0 scream and shout
+ if (TEST_ERRREF_RESULT)
+ message (FATAL_ERROR "Failed: The error output of ${TEST_OUTPUT}.err did not match ${TEST_ERRREF}")
+ endif ()
+ endif ()
+endif ()
+
+set (TEST_GREP_RESULT 0)
+if (TEST_GREP_COMPARE)
+ # now grep the output with the reference
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ list (LENGTH TEST_STREAM test_len)
+ if (test_len GREATER 0)
+ # TEST_REFERENCE should always be matched
+ string (REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM})
+ string (COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_GREP_RESULT)
+ if (NOT TEST_GREP_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}")
+ endif ()
+
+ string (REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM})
+ if (TEST_EXPECT)
+ # TEST_EXPECT (1) interprets TEST_FILTER as; NOT to match
+ string (LENGTH "${TEST_MATCH}" TEST_GREP_RESULT)
+ if (TEST_GREP_RESULT)
+ message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}")
+ endif ()
+ endif ()
+ endif ()
+endif ()
+
+# dump the output unless nodisplay option is set
+if (TEST_SKIP_COMPARE AND NOT TEST_NO_DISPLAY)
+ file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM)
+ execute_process (
+ COMMAND ${CMAKE_COMMAND} -E echo ${TEST_STREAM}
+ RESULT_VARIABLE TEST_RESULT
+ )
+endif ()
+
+if (NOT DEFINED ENV{HDF5_NOCLEANUP})
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}" AND NOT TEST_SAVE)
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT})
+ endif ()
+
+ if (EXISTS "${TEST_FOLDER}/${TEST_OUTPUT}.err")
+ file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err)
+ endif ()
+
+ if (TEST_DELETE_LIST)
+ foreach (dfile in ${TEST_DELETE_LIST})
+ file (REMOVE ${dfile})
+ endforeach ()
+ endif ()
+endif ()
+
+# everything went fine...
+message (STATUS "${TEST_PROGRAM} Passed")
+
diff --git a/HDF5Examples/config/toolchain/aarch64.cmake b/HDF5Examples/config/toolchain/aarch64.cmake
new file mode 100644
index 0000000..03f4e5e
--- /dev/null
+++ b/HDF5Examples/config/toolchain/aarch64.cmake
@@ -0,0 +1,17 @@
+set(TOOLCHAIN_PREFIX aarch64-linux-gnu)
+set(ANDROID_NDK /opt/android-ndk-linux)
+set (CMAKE_SYSTEM_NAME Android)
+set (CMAKE_ANDROID_ARCH_ABI x86_64)
+#set (CMAKE_ANDROID_STANDALONE_TOOLCHAIN ${ANDROID_NDK}/build/cmake/android.toolchain.cmake)
+set (CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+set (CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+#set (CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
+set (CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
+set (CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set (CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64)
+
+include_directories(/usr/${TOOLCHAIN_PREFIX}/include)
+
diff --git a/HDF5Examples/config/toolchain/build32.cmake b/HDF5Examples/config/toolchain/build32.cmake
new file mode 100644
index 0000000..f636ea8
--- /dev/null
+++ b/HDF5Examples/config/toolchain/build32.cmake
@@ -0,0 +1,79 @@
+if (WIN32)
+ set (CMAKE_SYSTEM_NAME Windows)
+ set (CMAKE_GENERATOR_PLATFORM "x86")
+elseif(APPLE)
+ set (CMAKE_OSX_ARCHITECTURES "i386")
+elseif(MINGW)
+ set (CMAKE_SYSTEM_NAME Windows)
+ set (TOOLCHAIN_PREFIX i686-w64-mingw32)
+ set (CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+ set (CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+ set (CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
+ set (CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
+
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
+
+ set (LIB32 /usr/lib) # Fedora
+
+ if (EXISTS "/usr/lib32")
+ set (LIB32 /usr/lib32) # Arch, Solus
+ endif ()
+
+ set (CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE)
+ set (CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE)
+
+ # this is probably unlikely to be needed, but just in case
+ set (CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE)
+ set (CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE)
+ set (CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE)
+
+ # on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have
+ # to include the regular system .pc files as well (at the end), because some
+ # are not always present in the 32 bit directory
+ if (EXISTS "${LIB32}/pkgconfig")
+ set (ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig)
+ endif ()
+
+ set (CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+ set (CMAKE_CROSSCOMPILING_EMULATOR wine)
+
+ include_directories(/usr/${TOOLCHAIN_PREFIX}/include)
+ set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS On CACHE BOOL "Export windows symbols")
+else ()
+ set (CMAKE_SYSTEM_NAME Linux)
+
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" CACHE STRING "c++ flags")
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32" CACHE STRING "c flags")
+
+ set (LIB32 /usr/lib) # Fedora
+
+ if (EXISTS "/usr/lib32")
+ set (LIB32 /usr/lib32) # Arch, Solus
+ endif ()
+
+ set (CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE)
+ set (CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE)
+
+ # this is probably unlikely to be needed, but just in case
+ set (CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE)
+ set (CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE)
+ set (CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE)
+
+ # on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have
+ # to include the regular system .pc files as well (at the end), because some
+ # are not always present in the 32 bit directory
+ if (EXISTS "${LIB32}/pkgconfig")
+ set (ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig)
+ endif ()
+# where is the target environment
+ set (CMAKE_FIND_ROOT_PATH ${LIB32})
+# search for programs in the build host directories
+ set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+# for libraries and headers in the target directories
+ set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+ set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+endif ()
diff --git a/HDF5Examples/config/toolchain/clang.cmake b/HDF5Examples/config/toolchain/clang.cmake
new file mode 100644
index 0000000..2d35641
--- /dev/null
+++ b/HDF5Examples/config/toolchain/clang.cmake
@@ -0,0 +1,16 @@
+# Uncomment the following to use cross-compiling
+#set (CMAKE_SYSTEM_NAME Linux)
+
+set (CMAKE_COMPILER_VENDOR "clang")
+
+if(WIN32)
+ set (CMAKE_C_COMPILER clang-cl)
+ set (CMAKE_CXX_COMPILER clang-cl)
+else()
+ set (CMAKE_C_COMPILER clang)
+ set (CMAKE_CXX_COMPILER clang++)
+endif()
+set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
+
+# the following is used if cross-compiling
+set (CMAKE_CROSSCOMPILING_EMULATOR "")
diff --git a/HDF5Examples/config/toolchain/crayle.cmake b/HDF5Examples/config/toolchain/crayle.cmake
new file mode 100644
index 0000000..02df8ff
--- /dev/null
+++ b/HDF5Examples/config/toolchain/crayle.cmake
@@ -0,0 +1,10 @@
+# The following line will use cross-compiling
+set (CMAKE_SYSTEM_NAME Linux)
+
+set (CMAKE_COMPILER_VENDOR "CrayLinuxEnvironment")
+
+set (CMAKE_C_COMPILER cc)
+set (CMAKE_Fortran_COMPILER ftn)
+
+# the following is used if cross-compiling
+set (CMAKE_CROSSCOMPILING_EMULATOR "")
diff --git a/HDF5Examples/config/toolchain/gcc.cmake b/HDF5Examples/config/toolchain/gcc.cmake
new file mode 100644
index 0000000..f0771ed
--- /dev/null
+++ b/HDF5Examples/config/toolchain/gcc.cmake
@@ -0,0 +1,11 @@
+# Uncomment the following line and the correct system name to use cross-compiling
+#set (CMAKE_SYSTEM_NAME Linux)
+
+set (CMAKE_COMPILER_VENDOR "GCC")
+
+set (CMAKE_C_COMPILER cc)
+set (CMAKE_CXX_COMPILER c++)
+set (CMAKE_Fortran_COMPILER gfortran)
+
+# the following is used if cross-compiling
+set (CMAKE_CROSSCOMPILING_EMULATOR "")
diff --git a/HDF5Examples/config/toolchain/icc.cmake b/HDF5Examples/config/toolchain/icc.cmake
new file mode 100644
index 0000000..97f6a64
--- /dev/null
+++ b/HDF5Examples/config/toolchain/icc.cmake
@@ -0,0 +1,11 @@
+# Uncomment the following to use cross-compiling
+#set(CMAKE_SYSTEM_NAME Linux)
+
+set(CMAKE_COMPILER_VENDOR "intel")
+
+set(CMAKE_C_COMPILER icc)
+set(CMAKE_CXX_COMPILER icpc)
+set(CMAKE_Fortran_COMPILER ifort)
+
+# the following is used if cross-compiling
+set(CMAKE_CROSSCOMPILING_EMULATOR "")
diff --git a/HDF5Examples/config/toolchain/intel.cmake b/HDF5Examples/config/toolchain/intel.cmake
new file mode 100644
index 0000000..f8f60b2
--- /dev/null
+++ b/HDF5Examples/config/toolchain/intel.cmake
@@ -0,0 +1,11 @@
+# Uncomment the following to use cross-compiling
+#set(CMAKE_SYSTEM_NAME Linux)
+
+set(CMAKE_COMPILER_VENDOR "intel")
+
+set(CMAKE_C_COMPILER icx)
+set(CMAKE_CXX_COMPILER icpx)
+set(CMAKE_Fortran_COMPILER ifx)
+
+# the following is used if cross-compiling
+set(CMAKE_CROSSCOMPILING_EMULATOR "")
diff --git a/HDF5Examples/config/toolchain/mingw64.cmake b/HDF5Examples/config/toolchain/mingw64.cmake
new file mode 100644
index 0000000..1b13891
--- /dev/null
+++ b/HDF5Examples/config/toolchain/mingw64.cmake
@@ -0,0 +1,14 @@
+set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
+set (CMAKE_SYSTEM_NAME Windows)
+set (CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
+set (CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
+set (CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
+set (CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
+set (CMAKE_FIND_ROOT_PATH /usr/${TOOLCHAIN_PREFIX})
+set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set (CMAKE_CROSSCOMPILING_EMULATOR wine64)
+
+include_directories(/usr/${TOOLCHAIN_PREFIX}/include)
+set (CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS On CACHE BOOL "Export windows symbols")
diff --git a/HDF5Examples/config/toolchain/pgi.cmake b/HDF5Examples/config/toolchain/pgi.cmake
new file mode 100644
index 0000000..ff2f048
--- /dev/null
+++ b/HDF5Examples/config/toolchain/pgi.cmake
@@ -0,0 +1,11 @@
+# Uncomment the following to use cross-compiling
+#set (CMAKE_SYSTEM_NAME Linux)
+
+set (CMAKE_COMPILER_VENDOR "PGI")
+
+set (CMAKE_C_COMPILER pgcc)
+set (CMAKE_CXX_COMPILER pgc++)
+set (CMAKE_Fortran_COMPILER pgf90)
+
+# the following is used if cross-compiling
+set (CMAKE_CROSSCOMPILING_EMULATOR "")