0

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?

vitaut
  • 49,672
  • 25
  • 199
  • 336
Irbis77
  • 163
  • 1
  • 8

1 Answers1

0

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

cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug ...
vitaut
  • 49,672
  • 25
  • 199
  • 336
  • Thanks. It actually worked. But now I am confused, I've got 41 compilation errors with the correct .lib and 19 with /MDd. The errors look like this: ``` LNK2038 mismatch detected for 'RuntimeLibrary': value 'MDd_DynamicDebug' doesn't match value 'MTd_StaticDebug' in main.obj vcruntime140 \vcruntime140\fmtd.lib(format.obj) ``` with /MDd – Irbis77 Jul 27 '21 at 18:58
  • 1
    The above is the correct answer. It seems to be possible to rebuild the fmt sub-project separetely from the rest of the solution as well once CMake finished working. And to specify /MTd for that compilation explicetely. – Irbis77 Jul 28 '21 at 20:27