Skip to content

Commit

Permalink
COMP: Simplify H5Tinit.c file generation
Browse files Browse the repository at this point in the history
ITK does not support many of the possible
build options for HDF5 generation of build-time
source files.  Commented out many of the unused
conditional build options to help identify the
relevant code paths that needed to be fixed.

Building with shared libraries with ninja
and CMake >= 3.22.1 resulted in failures due
to dependancy relationships that could not
be resolved by ninja.

```bash
ninja: error:
'Modules/ThirdParty/HDF5/src/itkhdf5/src/H5lib_settings.c', needed by
'Modules/ThirdParty/HDF5/src/itkhdf5/src/shared/H5lib_settings.c',
missing and no known rule to make it
```

https://cmake.org/cmake/help/latest/policy/CMP0058.html
  • Loading branch information
hjmjohnson committed Jan 6, 2022
1 parent 4eafe84 commit 568e311
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,9 @@ if (LOCAL_BATCH_TEST)
endif ()

set (lib_prog_deps)
#[[ ITK -- start
if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c")
# ITK -- stop ]]
add_executable (H5detect ${HDF5_SRC_DIR}/H5detect.c)
target_include_directories (H5detect PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
target_compile_definitions(H5detect PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
Expand All @@ -1059,13 +1061,14 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c")
)
set (lib_prog_deps ${lib_prog_deps} H5detect)

#[[ ITK -- start
if (HDF5_BATCH_H5DETECT)
configure_file (
${HDF5_SOURCE_DIR}/bin/batch/${HDF5_BATCH_H5DETECT_SCRIPT}.in.cmake
${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} ESCAPE_QUOTES @ONLY
)
add_custom_command (
OUTPUT gen_SRCS.stamp1
OUTPUT gen_SRCS.stamp1 H5Tinit.c
COMMAND ${HDF5_BATCH_CMD}
ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT}
BYPRODUCTS H5Tinit.c gen_SRCS.stamp1
Expand All @@ -1081,6 +1084,7 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c")
)
set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE)
else ()
# ITK -- stop ]]
add_custom_command (TARGET H5detect POST_BUILD
COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5detect>
ARGS H5Tinit.c
Expand All @@ -1105,7 +1109,10 @@ if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c")
)
set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE)
endif ()
#[[ ITK -- start
endif ()
# ITK -- stop ]]
#[[ ITK -- start
else ()
add_custom_command (
OUTPUT gen_SRCS.stamp1
Expand All @@ -1131,6 +1138,7 @@ else ()
set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE)
endif ()
endif ()
# ITK -- stop ]]

#-----------------------------------------------------------------------------
# Add Target to clang-format
Expand Down

0 comments on commit 568e311

Please sign in to comment.