Search code examples
cmakefmt

How to build MTd lib for fmt format library?


I am trying to use the following library here: https://github.com/fmtlib/fmt

It builds OK using the cmake file provided.

But as part of the build it generates fmtd.lib file, which by default is in MD Dynamic Library format.

I need to rebuild it to be MTd Static Debug lib.

I've tried to modify the CmakeLists.txt file with below settings:

if (MSVC)
  set(PEDANTIC_COMPILE_FLAGS /W3 /MTd)
  set(WERROR_FLAG /WX)
  set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif ()

which didn't seem to work.

Any ideas of how to change it so it builds the correct version of fmtd.lib?


Solution

  • You should be able to do this via the CMAKE_MSVC_RUNTIME_LIBRARY CMake variable:

    cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug ...