CMake Generated VS 2022 Project File references to the library "rt.lib" instead of "msvcrt.lib"

Hello,

When I build my project, I get the following error message:

LINK : fatal error LNK1181: cannot open input file 'rt.lib' [D:\conan2-libraries\hdbreader-source\build-release\src\tests\SavecaseReader_unittest\SavecaseReader_unittest.vcxproj]

I tried setting the following in my CMakeLists.txt file.

cmake_policy(SET CMP0091 NEW)
..
..
set_target_property(${target_name} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")

But no effect.

Also tried the following:

target_link_options(${target_name} PRIVATE "/NODEFAULTLIB:rt.lib") 
set_target_properties(${target_name} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:rt.lib") 

But no impact.

If I manually edit the generated Visual Studio Project file to use “msvcrt.lib”, it builds.

Actually, there is no library file named “rt.lib”.

I am using cmake Version 3.26.4. Also tried with CMake 3.31.8 without Success.

This issue is not there with VS 2019 & CMake 22.3. It builds successfully with CMake Version3.22.3 with Visual Studio 2019.

I was able to resolve the issue. Actually, it was referring to librt.so

It was my mistake and I didn’t put the Cmake Generator Exression for GNU Compilation only.