Building Debug on Window

General Setting

My goal is to build smtk (and later, cmb) in Debug. The problem is that cmb-superbuild does not allow Debug builds.

To work around this limitation, I want to build cmb-superbuild in RelWithDebugInfo, while also setting:

  • /MDd /DWIN32 compiler flags
  • _ITERATOR_DEBUG_LEVEL=0 (in the downstream projects, not cmb-superbuild)

As I understand it, this should allow the subsequent build of smtk to be Debug, even though smb-superbuild is built in RelWithDebInfo.

Steps Taken

_ITERATOR_DEBUG_LEVEL

The command line argument -D_ITERATOR_DEBUG_LEVEL=0 does not seem to work, and instead the following line needs to be added to the main CMakeLists.txt file:

add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)

It is unclear to me so far whether it is better to:

  1. set _ITERATOR_DEBUG_LEVEL=2 in cmb-superbuild, or
  2. set _ITERATOR_DEBUG_LEVEL=0 in smtk (and later, cmb)

I have not yet had a chance to test these two options.

/MDd /DWIN32 compiler flags

These compiler flags are set using these cmake commands:

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MDd /DWIN32")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd /DWIN32")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MDd /DWIN32")

The /MDd does not seem to propagate, and so must be set at every level of cmb-superbuild. So far, these lines of code are added to:

  • CMakeLists.txt
  • projects\paraview.cmake
  • projects\vtk.cmake
  • projects\vtkonly.cmake
  • projects\win32\moab.cmake
  • superbuild\projects\win32\boost.cmake

Problem

For most parts of cmb-superbuild, the above steps work well. However, this fails for VTK within paraview. Specifically, we get hundreds/thousands of compile errors like:

cl : Command line warning D9025 : overriding '/MDd' with '/MD' 

I cannot find any other likely locations where I should insert the compiler flags definitions to get past these compile errors.

How can I prevent paraview from overriding my specified flags?

@ben.boeckel Can you take a look at this?

This is pointless. Don’t set it. It is really spelled _WIN32 and is set by any sensible compiler. Anything relying on WIN32 should be fixed.

Why would it? That sets a CMake variable (about which nothing cares about).

MSVC runtime is now selected by the MSVC_RUNTIME_LIBRARY property. Do not set it via flags manually. Instead, you can use the CMAKE_MSVC_RUNTIME_LIBRARY variable. Note that projects which are not aware of CMake 3.15 will ignore this. We should make these projects CMP0091-aware instead.

This is because these projects are CMP0091-aware and do not expect the runtime to be set manually outside of the property.

Given the advice above (and recent progress with building libarchive in Debug), I’ve shifted back to trying to build all needed parts of cmb-superbuild in Debug rather than pursuing a hybrid approach.

To that end, I need to be able to build the following parts of cmb-superbuild in order to move on to building smtk (for further use building cmb):

  • boost
  • libarchive
  • moab
  • nlohmannjson
  • paraview
  • pegtl
  • pybind11

I’m trying to build the smaller modules before moving on to paraview. So far, they all build in Debug except for moab.

The moab build fails within netcdf due to an error in hdf5. Here is the specific error from netcdf-build-err.log:

ninja: error: 'C:/projects/cmb-BenMR/5_15_2_VS19_64D/install/lib/hdf5.lib', needed by 'liblib/netcdf.dll', missing and no known rule to make it
CMake Error at C:/projects/cmb-BenMR/5_15_2_VS19_64D/superbuild/sb-netcdf-build.cmake:47 (message):
  Failed with exit code 1

There is a hdf5_D.lib present in the build directory, but no hdf5.lib.

Do you have any advice or suggestions in regard to this error?