I have a project that depends on HDF5. A user can either specify an existing installation and thus use a find_package or choose to have HDF5 built with the project. I've been using Paraview as a template to implement this but I can't seem to get the dependencies for my project defined correctly when it builds HDF5.

So what I'm doing is an ExternalProject_Add command like this:

ExternalProject_Add(hdf5
                       URL     ${HDF5_url}/${HDF5_gz}
                       URL_MD5 ${HDF5_md5}
                       UPDATE_COMMAND ""
                       PREFIX  ${HDF5_prefix}
                       CMAKE_ARGS
                          -DBUILD_SHARED_LIBS:Bool=OFF
                          -DBUILD_TESTING:Bool=OFF
                          -DHDF5_ENABLE_Z_LIB_SUPPORT:Bool=ON
                          -DZLIB_INCLUDE_DIR:STRING=${ZLIB_INCLUDE_DIR}
                          -DZLIB_LIBRARY:STRING=${ZLIB_LIBRARY}
                          -DHDF5_BUILD_HL_LIB:Bool=ON
                          -DHDF5_BUILD_TOOLS:Bool=ON
                          -DCMAKE_INSTALL_PREFIX:PATH=${HDF5_prefix}
                       )

and then to be consistent with the find_package logic, I define HDF5_INCLUDE_DIR, HDF5_LIBRARIES based on the installation paths I know eventually will exist like this

set(HDF5_LIBRARY_DIR "${HDF5_prefix}/lib")
set(HDF5_LIBRARY "${HDF5_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}hdf5${CMAKE_STATIC_LIBRARY_PREFIX}") set(HDF5_HL_LIBRARY "${HDF5_LIBRARY_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}hdf5_hl${CMAKE_STATIC_LIBRARY_PREFIX}")

set(HDF5_LIBRARIES "${HDF5_HL_LIBRARY};${HDF5_LIBRARY}")

and then when I need to build a binary that links against HDF5, I have in a CMakeLists.txt file

add_executable(test.x ${test_src_files})
target_link_libraries(test.x ${HDF5_LIBRARIES})

But at build time I see errors complaining about "No rule to make target <path to HDF5_prefix>/libhdf5.a needed for test.x". I am confused. Do I need to do more than just define HDF5_LIBRARIES? Do I need to define libhdf5.a as a target? How do I do that? Defining libhd5 through add_library( .. UNKNOWN IMPORTED) call does seem right because they are not imported.





--
Lori A. Pritchett-Sheats, PhD.
CCS-2, Computational Physics and Methods
Office: 505-665-6675
Fax: 505-665-4972

Los Alamos National Laboratory
P.O. Box 1663
MS D413
Los Alamos, NM 87544

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to