summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/cmake/HDF5ExampleCache.cmake18
-rw-r--r--config/cmake/HDFMacros.cmake5
-rw-r--r--config/cmake/UseJava.cmake99
-rw-r--r--config/cmake/javaTargets.cmake.in3
4 files changed, 116 insertions, 9 deletions
diff --git a/config/cmake/HDF5ExampleCache.cmake b/config/cmake/HDF5ExampleCache.cmake
index 043be1a..f5fb620 100644
--- a/config/cmake/HDF5ExampleCache.cmake
+++ b/config/cmake/HDF5ExampleCache.cmake
@@ -23,6 +23,23 @@ set (H5EX_HDF5_INCLUDE_DIRS "${HDF5_SRC_INCLUDE_DIRS};${HDF5_SRC_BINARY_DIR}" CA
set (H5EX_HDF5_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE STRING "HDF5 build folder" FORCE)
set (EXAMPLES_EXTERNALLY_CONFIGURED ON CACHE BOOL "Examples build is used in another project" FORCE)
+set (EXAMPLE_VARNAME "H5")
+set (H5EX_RESOURCES_DIR ${HDF_RESOURCES_DIR})
+message (STATUS "HDF5 Example H5EX_RESOURCES_DIR: ${H5EX_RESOURCES_DIR}")
+if (DEFAULT_API_VERSION MATCHES "v16")
+ set (H5_LIBVER_DIR 16)
+elseif (DEFAULT_API_VERSION MATCHES "v18")
+ set (H5_LIBVER_DIR 18)
+elseif (DEFAULT_API_VERSION MATCHES "v110")
+ set (H5_LIBVER_DIR 110)
+elseif (DEFAULT_API_VERSION MATCHES "v112")
+ set (H5_LIBVER_DIR 112)
+elseif (DEFAULT_API_VERSION MATCHES "v114")
+ set (H5_LIBVER_DIR 114)
+elseif (DEFAULT_API_VERSION MATCHES "v116")
+ set (H5_LIBVER_DIR 116)
+endif ()
+
if (NOT BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS)
set (USE_SHARED_LIBS OFF CACHE BOOL "Use Shared Libraries for Examples" FORCE)
set (H5EX_HDF5_LINK_LIBS ${HDF5_LIB_TARGET} CACHE STRING "HDF5 target" FORCE)
@@ -53,3 +70,4 @@ message (STATUS "HDF5 Example link libs: ${H5EX_HDF5_LINK_LIBS} Includes: ${H5EX
set (HDF5_TOOLS_DIR ${CMAKE_TEST_OUTPUT_DIRECTORY} CACHE STRING "HDF5 Directory for all Executables" FORCE)
set (H5EX_HDF5_DUMP_EXECUTABLE $<TARGET_FILE:h5dump${tgt_file_ext}> CACHE STRING "HDF5 h5dump target" FORCE)
set (H5EX_HDF5_REPACK_EXECUTABLE $<TARGET_FILE:h5repack${tgt_file_ext}> CACHE STRING "HDF5 h5repack target" FORCE)
+
diff --git a/config/cmake/HDFMacros.cmake b/config/cmake/HDFMacros.cmake
index 369df96..30c16e6 100644
--- a/config/cmake/HDFMacros.cmake
+++ b/config/cmake/HDFMacros.cmake
@@ -482,9 +482,7 @@ macro (HDF_DIR_PATHS package_prefix)
endif ()
SET_HDF_BUILD_TYPE()
-#-----------------------------------------------------------------------------
-# Setup output Directories
-#-----------------------------------------------------------------------------
+
SET_HDF_OUTPUT_DIRS(${package_prefix})
include (FetchContent)
@@ -510,4 +508,3 @@ macro (ADD_H5_FLAGS h5_flag_var infile)
endif ()
#message (TRACE "h5_flag_var=${${h5_flag_var}}")
endmacro ()
-
diff --git a/config/cmake/UseJava.cmake b/config/cmake/UseJava.cmake
index 2783cb6..12e324c 100644
--- a/config/cmake/UseJava.cmake
+++ b/config/cmake/UseJava.cmake
@@ -6,7 +6,7 @@ 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.
+information on how to load Java into your CMake project.
Synopsis
^^^^^^^^
@@ -42,6 +42,7 @@ Creating And Installing JARs
add_jar(<target_name>
[SOURCES] <source1> [<source2>...] [<resource1>...]
+ [RESOURCES NAMESPACE <ns1> <resource1>... [NAMESPACE <nsX> <resourceX>...]... ]
[INCLUDE_JARS <jar1> [<jar2>...]]
[ENTRY_POINT <entry>]
[VERSION <version>]
@@ -64,6 +65,34 @@ Creating And Installing JARs
.. versionadded:: 3.4
Support for response files, prefixed by ``@``.
+ ``RESOURCES``
+ .. versionadded:: 3.21
+
+ Adds the named ``<resource>`` files to the jar by stripping the source file
+ path and placing the file beneath ``<ns>`` within the jar.
+
+ For example::
+
+ RESOURCES NAMESPACE "/com/my/namespace" "a/path/to/resource.txt"
+
+ results in a resource accessible via ``/com/my/namespace/resource.txt``
+ within the jar.
+
+ Resources may be added without adjusting the namespace by adding them to
+ the list of ``SOURCES`` (original behavior), in this case, resource
+ paths must be relative to ``CMAKE_CURRENT_SOURCE_DIR``. Adding resources
+ without using the ``RESOURCES`` parameter in out of source builds will
+ almost certainly result in confusion.
+
+ .. note::
+
+ Adding resources via the ``SOURCES`` parameter relies upon a hard-coded
+ list of file extensions which are tested to determine whether they
+ compile (e.g. File.java). ``SOURCES`` files which match the extensions
+ are compiled. Files which do not match are treated as resources. To
+ include uncompiled resources matching those file extensions use
+ the ``RESOURCES`` parameter.
+
``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
@@ -264,7 +293,7 @@ Header Generation
.. 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>`_.
+ due to the `suppression of javah tool <https://openjdk.org/jeps/313>`_.
The :ref:`add_jar(GENERATE_NATIVE_HEADERS) <add_jar>` command should be
used instead.
@@ -526,6 +555,7 @@ function (__java_copy_file src dest comment)
${dest}
DEPENDS ${src}
COMMENT ${comment}
+ VERBATIM
)
endfunction ()
@@ -552,6 +582,58 @@ function(__java_export_jar VAR TARGET PATH)
set(${VAR} "${${VAR}}" PARENT_SCOPE)
endfunction()
+function(__java_copy_resource_namespaces VAR DEST JAVA_RESOURCE_FILES JAVA_RESOURCE_FILES_RELATIVE)
+
+ set(_ns_ID "")
+ set(_ns_VAL "")
+
+ foreach(_item IN LISTS VAR)
+ if(NOT _ns_ID)
+ if(NOT _item STREQUAL "NAMESPACE")
+ message(FATAL_ERROR "UseJava: Expecting \"NAMESPACE\", got\t\"${_item}\"")
+ return()
+ endif()
+ endif()
+
+ if(_item STREQUAL "NAMESPACE")
+ set(_ns_VAL "") # Prepare for next namespace
+ set(_ns_ID "${_item}")
+ continue()
+ endif()
+
+ if( NOT _ns_VAL)
+ # we're expecting the next token to be a namespace value
+ # whatever it is, we're treating it like a namespace
+ set(_ns_VAL "${_item}")
+ continue()
+ endif()
+
+ if(_ns_ID AND _ns_VAL)
+ # We're expecting a file name, check to see if we got one
+ cmake_path(ABSOLUTE_PATH _item OUTPUT_VARIABLE _test_file_name)
+ if (NOT EXISTS "${_test_file_name}")
+ message(FATAL_ERROR "UseJava: File does not exist:\t${_item}")
+ return()
+ endif()
+ endif()
+
+ cmake_path(ABSOLUTE_PATH _item OUTPUT_VARIABLE _abs_file_name)
+ cmake_path(GET _item FILENAME _resource_file_name)
+ set(_dest_resource_file_name "${_ns_VAL}/${_resource_file_name}" )
+
+ __java_copy_file( ${_abs_file_name}
+ ${DEST}/${_dest_resource_file_name}
+ "Copying ${_item} to the build directory")
+
+ list(APPEND RESOURCE_FILES_LIST ${DEST}/${_dest_resource_file_name})
+ list(APPEND RELATIVE_RESOURCE_FILES_LIST ${_dest_resource_file_name})
+
+ endforeach()
+
+ set(${JAVA_RESOURCE_FILES} "${RESOURCE_FILES_LIST}" PARENT_SCOPE)
+ set(${JAVA_RESOURCE_FILES_RELATIVE} "${RELATIVE_RESOURCE_FILES_LIST}" 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)
@@ -746,6 +828,13 @@ function(add_jar _TARGET_NAME)
endif ()
endforeach()
+ if(_add_jar_RESOURCES) # Process RESOURCES if it exists
+ __java_copy_resource_namespaces("${_add_jar_RESOURCES}"
+ ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
+ _JAVA_RESOURCE_FILES
+ _JAVA_RESOURCE_FILES_RELATIVE)
+ endif()
+
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)
@@ -792,9 +881,10 @@ function(add_jar _TARGET_NAME)
${_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}
+ DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} ${_JAVA_SOURCES_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
+ VERBATIM
)
add_custom_command(
OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
@@ -804,6 +894,7 @@ function(add_jar _TARGET_NAME)
-P ${_JAVA_CLASS_FILELIST_SCRIPT}
DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ VERBATIM
)
else ()
# create an empty java_class_filelist
@@ -834,6 +925,7 @@ function(add_jar _TARGET_NAME)
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}"
+ VERBATIM
)
else ()
add_custom_command(
@@ -849,6 +941,7 @@ function(add_jar _TARGET_NAME)
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}"
+ VERBATIM
)
endif ()
diff --git a/config/cmake/javaTargets.cmake.in b/config/cmake/javaTargets.cmake.in
index 6e14256..f3670c2 100644
--- a/config/cmake/javaTargets.cmake.in
+++ b/config/cmake/javaTargets.cmake.in
@@ -1,6 +1,5 @@
-cmake_minimum_required(VERSION 2.8.12)
cmake_policy(PUSH)
-cmake_policy(VERSION 2.8)
+cmake_policy(VERSION 2.8.12...3.27)
#----------------------------------------------------------------
# Generated CMake Java target import file.