Build both release and debug


Hi, I’m currently trying to use the HDF library in an application. I build the application using CMake on Windows with the Visual Studio 2017 Compiler. I was able to build the HDF library using the provided batch script, copy the result to my project, set the HDF5_DIR variable and use find_package to include the library. However, the HDF library was only build in release mode and so now my release build succeeds but the debug build fails because it can’t find a matching lib. Is there a way to build both release and debug of the HDF5 library and use it with CMake?


Currently we do not support building both debug and release at the same time. You would need to compile each of (Release, RelWithDebInfo, Debug) with separate build runs.



I solved it by building both version and conditionally setting the HDF5_DIR in the CMakeLists.txt.

    set(ENV{HDF5_DIR} "${CMAKE_CURRENT_LIST_DIR}/libs/HDF5-1.10.4-win64-Debug/cmake")
    set(ENV{HDF5_DIR} "${CMAKE_CURRENT_LIST_DIR}/libs/HDF5-1.10.4-win64-Release/cmake")
find_package(HDF5 NAMES hdf5 COMPONENTS CXX CXX_HL static)


Note that the RelWithDebInfo build will create the .pdb files for windows debugging.