You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I'm trying to add HDF5 using cpm.make without success.
It basically won't compiler, although detection seems to run.
I followed some of the examples, which run fine. What am I doing wrong ?
For the record, I'm far from being a pro with CMake, so, please, be forgiving :-)
Any help would be appreciated. Thanks.
Here is the CMakeLists.txt I ended with:
cmake_minimum_required(VERSION 3.28)
project(MyApp LANGUAGES CXX C)
# Standards
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# set-up cpm.cmake
set(CPM_SOURCE_CACHE ~/.cache/cpm/)
set(CPM_DOWNLOAD_VERSION 0.40.8)
set(CPM_HASH_SUM "78ba32abdf798bc616bab7c73aac32a17bbd7b06ad9e26a6add69de8f3ae4791")
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/get_cpm.cmake)
# Try to add hdf5
CPMAddPackage(
NAME hdf5
GIT_REPOSITORY https://github.com/HDFGroup/hdf5.git
GIT_TAG hdf5-1.14.6
OPTIONS
"HDF5_BUILD_EXAMPLES OFF"
"HDF5_BUILD_TESTING OFF"
"HDF5_BUILD_TOOLS OFF"
"HDF5_ENABLE_SZIP_SUPPORT OFF"
"HDF5_ENABLE_ZLIB_SUPPORT ON"
)
# Check if HDF5 was successfully added
if(NOT hdf5_ADDED)
message(FATAL_ERROR "Failed to add HDF5 to the project")
endif()
# Otherwise "Error: The dependency target "hdf5" of target "my_app" does not exist."
add_library(hdf5 INTERFACE IMPORTED)
# Otherwise missing headers
target_include_directories(hdf5 INTERFACE
"${hdf5_BINARY_DIR}/src"
"${hdf5_SOURCE_DIR}/src"
"${hdf5_SOURCE_DIR}/src/H5FDsubfiling"
"${hdf5_SOURCE_DIR}/c++/src")
add_executable(my_app src/main.cpp)
target_link_libraries(my_app PRIVATE
hdf5
z
)
add_dependencies(my_app hdf5)
And an excerpt of the output:
$ cmake ..
...
-- Looking for FLT16_MAX_10_EXP - found
-- Looking for FLT16_MANT_DIG
-- Looking for FLT16_MANT_DIG - found
-- Looking for fabsf16
-- Looking for fabsf16 - not found
-- Found Perl: /usr/bin/perl (found version "5.40.1")
-- ... disable color and URL extended diagnostic messages
-- ....All Warnings are enabled
-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.3.1")
-- CPM: Adding package hdf5@ (hdf5-1.14.6 at /home/demo/.cache/cpm/hdf5/1330814d7933c78d7a1495dbccc2c35fe961b5a4)
-- Configuring done (13.8s)
-- Generating done (0.1s)
-- Build files have been written to: /home/demo/test/build
$ make
[ 0%] Building CXX object CMakeFiles/my_app.dir/src/main.cpp.o
[ 1%] Linking CXX executable my_app
/usr/bin/ld: CMakeFiles/my_app.dir/src/main.cpp.o: in function `main':
...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hi I'm trying to add HDF5 using cpm.make without success.
It basically won't compiler, although detection seems to run.
I followed some of the examples, which run fine. What am I doing wrong ?
For the record, I'm far from being a pro with CMake, so, please, be forgiving :-)
Any help would be appreciated. Thanks.
Here is the CMakeLists.txt I ended with:
And an excerpt of the output:
Beta Was this translation helpful? Give feedback.
All reactions