Hello @meemknight! I may have discovered an issue with your way of setting CMAKE_MSVC_RUNTIME_LIBRARY
I will refer to this snippet, as this is how you set it up in your cmakeSetup video
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>:Release>")
In theory this should set CMAKE_MSVC_RUNTIME_LIBRARY to MultiThreadedRelease when config is Release and MultiThreadedDebug when config is debug. Correct me if I'm wrong, but I see two different issues here:
Firstly, if we take a look at official documentation of cmake for CMAKE_MSVC_RUNTIME_LIBRARY, we find that MultiThreadedRelease is not an allowed value for CMAKE_MSVC_RUNTIME_LIBRARY, which is the first issue I've encountered when trying to link runtime statically. The correct value for release configuration is simply MultiThreaded
Lastly, using set() twice for CMAKE_MSVC_RUNTIME_LIBRARY causes it to be overwritten by the latest call. I replaced static runtime with dynamic and after running dumpbin /dependents on built files I have proven that this usage of set() does not work. I have later adjusted the snipped and received the correct linking results
So, here's how this should look like (the similar example can be found in already mentioned CMAKE_MSVC_RUNTIME_LIBRARY documentation):
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Fun fact: if we switch places in your snippet to set release first, as your do in most your repos, like so:
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Release>:Release>")
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
everything will work correctly, since first we always set release value, which may be invalid (MultiThreadedRelease), but then we always overwrite it with correct values (MultiThreaded for release and MultiThreadedDebug for debug).
I would advise you fix this in all your cmake setup repos, as release line is wrong and obsolete, and will break if placed after debug line
Thank you for your attention!
Hello @meemknight! I may have discovered an issue with your way of setting
CMAKE_MSVC_RUNTIME_LIBRARYI will refer to this snippet, as this is how you set it up in your cmakeSetup video
In theory this should set
CMAKE_MSVC_RUNTIME_LIBRARYtoMultiThreadedReleasewhen config isReleaseandMultiThreadedDebugwhen config is debug. Correct me if I'm wrong, but I see two different issues here:Firstly, if we take a look at official documentation of cmake for CMAKE_MSVC_RUNTIME_LIBRARY, we find that
MultiThreadedReleaseis not an allowed value forCMAKE_MSVC_RUNTIME_LIBRARY, which is the first issue I've encountered when trying to link runtime statically. The correct value for release configuration is simplyMultiThreadedLastly, using
set()twice forCMAKE_MSVC_RUNTIME_LIBRARYcauses it to be overwritten by the latest call. I replaced static runtime with dynamic and after runningdumpbin /dependentson built files I have proven that this usage of set() does not work. I have later adjusted the snipped and received the correct linking resultsSo, here's how this should look like (the similar example can be found in already mentioned CMAKE_MSVC_RUNTIME_LIBRARY documentation):
Fun fact: if we switch places in your snippet to set release first, as your do in most your repos, like so:
everything will work correctly, since first we always set release value, which may be invalid (
MultiThreadedRelease), but then we always overwrite it with correct values (MultiThreadedfor release andMultiThreadedDebugfor debug).I would advise you fix this in all your cmake setup repos, as release line is wrong and obsolete, and will break if placed after debug line
Thank you for your attention!