Prefer `h5hlcc`, `h5hlc++`, and `h5hlfc` compilers when HDF5's HL libraries
are requested. These include the `-lhdf_hl` in the command line, whereas
the non-hl compilers (like `h5cc`) do not. Using the latter, therefore,
leads to cmake complaining about not finding the `HDF5_HL` libraries even
though they are present in the same location as the `hdf5` library itself.
Fixes: #23261
Since commit d74210a8bd (CMP0017: Remove support for OLD behavior,
2024-11-17) we can rely on CMP0017's NEW behavior unconditionally.
Calling `include(FindPackageHandleStandardArgs)` in a builtin module
will always get the builtin `FindPackageHandleStandardArgs`.
Previously the not-found message confusingly mentioned an empty version
number:
-- Could NOT find HDF5: Found unsuitable version "", ...
Don't confuse FindPackageHandleStandardArgs by defining an empty
version.
Some HDF5 compiler wrappers do not support source file paths that
contain spaces. Pass source files to them using a file name in the
current working directory to avoid spaces.
Since commit 14c46fb16a (FindHDF5: Find C component with only CXX
compiler, 2022-12-13, v3.26.0-rc1~175^2), if CXX is enabled but C is
not, the `_HDF5_test_regular_compiler_C` helper writes a `.cpp` source
but the `_HDF5_invoke_compiler` still expects a `.c` source. Refactor
the logic to select a name for the source file up front, and use it in
both helpers.
Fixes: #24627
Issue: #24241
To detect Parallel HDF5, the output of `h5pcc -showconfig` was compared
with `Parallel HDF5: yes`. However, the Boolean flag is not always
`yes` or `no`, because it was set by the value in `HDF5_ENABLE_PARALLEL`
if CMake was used for the configuration. This commit instead checks to
see if the value is interpreted by CMake as "true".
Modify most of the modules that ship with CMake to use the new
try_compile / try_run signatures added by commit aa9220d3a0
(try_compile: Add keyword-dispatched signature, 2022-09-02). This
improves debugging by each invocation using its own directory so that
the results of multiple invocations can be retained.
This does not cover any invocations which provide an entire project, as
that flavor of try_compile has not yet been updated.
Revert commit e4e309f165 (FindHDF5: Add explicit library location
instead of guessed library name., 2022-03-22, v3.24.0-rc1~375^2).
The old behavior was not a guessed library name, but the name of an
imported target that can contain per-config locations and encode usage
requirements. Although find modules do not normally return their
imported target names in the `_LIBRARIES` variable, FindHDF5 has done so
since commit 5201a3065b (FindHDF5: use the target rather than the path,
2017-01-04, v3.8.0-rc1~81^2).
Fixes: #23667
Check that the file that is accessed via `file(STRINGS...)` truly
exists.
This is not the case in some EMSCRIPTEN/WebASM builds where we want to
overwrite the HDF5 find logic manually. The missing check here prevents
that one can overwrite the search logic in exotic environments.
Update the imported target locations added by commit a8e0a6b3e4
(FindHDF5: Port changes from VTK, 2020-06-10, v3.19.0-rc1~312^2~1) to
use config-specific locations.
Issue: #21637
The imported targets added by commit a8e0a6b3e4 (FindHDF5: Port changes
from VTK, 2020-06-10, v3.19.0-rc1~312^2~1) to use config-specific
locations set the `IMPORTED_IMPLIB` target property. That property has
no meaning for an imported library with type `UNKNOWN`. Drop it to
avoid confusion.
When the HDF5 HL library is not available, FindHDF5 with Fortran does
not work. The problem is because `cmake_hdf5_test.f90` tries to
"use h5lt" and "use h5ds", which comes from the HL library.
Then the basic compiler check fails completely.
The two "use" lines were added by commit 00405af0f1 (HDF5: Refactor the
use of compiler wrappers, 2016-04-04, v3.6.0-rc1~85^2) along with the
rest of the check. Remove them.
Fixes: #22890
247f1149e1 FindHDF5: clear language-specific libraries list before discovery
f56963cf05 FindHDF5: clear library output variables at the top of the module
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !6698
Divert LCC compiler as a new one, instead of treating it as GNU.
Since old times, Elbrus C/C++/Fortran Compiler (LCC) by MCST has been
passing checks for GNU compilers, so it has been identified as GNU.
Now, with intent of seriously upstreaming its support, it has been
added as a separate LCC compiler, and its version displays not a
supported GCC version, but LCC version itself (e.g. LCC 1.25.19 instead
of GNU 7.3.0).
This commit adds its support for detection, and also converts basically
every check like 'is this compiler GNU?' to 'is this compiler GNU or
LCC?'. The only places where this check is untouched, is where it
regards other platforms where LCC is unavailable (primarily non-Linux),
and where it REALLY differs from GNU compiler.
Note: this transition may break software that are already ported to
Elbrus, but hardly relies that LCC will be detected as GNU; still such
software is not known.
b924669385 FindHDF5: silence STATUS messages when found with QUIET
2439a048b0 FindHDF5: avoid writing to the output when testing h5cc
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5722
The execution of this tool can output error logs to the output during
configure. This can then be caught by CTest and flagged as an error
during the build.
* When both debug and optimized libraries are found, the corresponding
keywords were getting de-duplicated and breaking.
* CMake's link line generation de-duplicates in many cases anyway.
* Other find modules do not explicitly de-duplicate in general.
Fixes: #21670
Use `list(REMOVE_DUPLICATES)` directly. For definitions the order
doesn't matter. For include directories it is better to remove late
duplicates than early duplicates.
Use `target_link_libraries` to set `INTERFACE_LINK_LIBRARIES` so that
the `debug` and `optimized` keywords work.
In commit a8e0a6b3e4 (FindHDF5: Port changes from VTK, 2020-06-10,
v3.19.0-rc1~312^2~1) we added use of `HDF5_LIBRARIES`, but the value may
contain `debug` and `optimized` keywords.
Fixes: #21637
A valid HDF5 installation with the "high level" extensions not
configured will *fail* to be correctly detected by CMake since
commit d9e39f3f89 (FindHDF5: check that compiler wrapper can
compile a minimal program, 2020-02-10, v3.18.0-rc1~744^2~1):
```
/.../hdf5/cmake_hdf5_test.c:2:10: fatal error: 'hdf5_hl.h' file not found
```
This does not stop the configuration but does prevent flags and
libraries from being recognized.