Build both release and debug


#1

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?


#2

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.

Allen


#3

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

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

#4

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

Allen