@@ -47,20 +47,45 @@ function(cxx_qt_import_crate)
47
47
48
48
if ((NOT CXX_QT_SUPPRESS_MSVC_RUNTIME_WARNING)
49
49
AND (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
50
- AND (CMAKE_BUILD_TYPE STREQUAL "Debug" )
51
- AND (NOT (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDLL" )))
52
- message (WARNING
53
- " CXX-Qt Warning: CMAKE_MSVC_RUNTIME_LIBRARY not set in MSVC Debug build!\n \n "
54
- " To fix this, set CMAKE_MSVC_RUNTIME_LIBRARY=\" MultiThreadedDLL\" when configuring.\n \n "
55
- " When building with MSVC in Debug, the CMAKE_MSVC_RUNTIME_LIBRARY variable should be set to \" MultiThreadedDLL\"\n "
56
- " This needs to be done before configuring any target that links to a Rust target.\n "
57
- " Otherwise, you may encounter linker errors when linking to Rust targets, like:\n \n "
58
- " error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ...\n \n "
59
- " See also:\n "
60
- " https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets\n "
61
- " and: https://github.com/KDAB/cxx-qt/pull/683\n \n "
62
- " To suppress this warning set CXX_QT_SUPPRESS_MSVC_RUNTIME_WARNING to ON"
63
- )
50
+ AND (CMAKE_BUILD_TYPE STREQUAL "Debug" ))
51
+ if (NOT (CMAKE_MSVC_RUNTIME_LIBRARY STREQUAL "MultiThreadedDLL" ))
52
+ message (WARNING
53
+ " CXX-Qt Warning: CMAKE_MSVC_RUNTIME_LIBRARY not set in MSVC Debug build!\n \n "
54
+ " To fix this, set CMAKE_MSVC_RUNTIME_LIBRARY=\" MultiThreadedDLL\" when configuring.\n \n "
55
+ " When building with MSVC in Debug, the CMAKE_MSVC_RUNTIME_LIBRARY variable should be set to \" MultiThreadedDLL\"\n "
56
+ " This needs to be done before configuring any target that links to a Rust target.\n "
57
+ " Otherwise, you may encounter linker errors when linking to Rust targets, like:\n \n "
58
+ " error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in ...\n \n "
59
+ " See also:\n "
60
+ " https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets\n "
61
+ " and: https://github.com/KDAB/cxx-qt/pull/683\n \n "
62
+ " To suppress this warning set CXX_QT_SUPPRESS_MSVC_RUNTIME_WARNING to ON"
63
+ )
64
+ else ()
65
+ set (QT_COMPONENTS_DEBUG_MODE "" )
66
+ foreach (QT_COMPONENT ${IMPORT_CRATE_QT_MODULES} )
67
+ get_target_property (QT_COMPONENT_RUNTIME ${QT_COMPONENT} MAP_IMPORTED_CONFIG_DEBUG )
68
+ if (NOT (QT_COMPONENT_RUNTIME STREQUAL "RELEASE" ))
69
+ list (APPEND QT_COMPONENTS_DEBUG_MODE ${QT_COMPONENT} )
70
+ endif ()
71
+ endforeach ()
72
+
73
+ if (QT_COMPONENTS_DEBUG_MODE)
74
+ message (WARNING
75
+ " CXX-Qt Warning: Found Qt component(s) that may link to the MSVC Debug runtime!\n \n "
76
+ " To fix this, set the MAP_IMPORTED_CONFIG_DEBUG property of the Qt component to \" RELEASE\" .\n \n "
77
+ " e.g.: set_property(Qt6::Core Qt6::Qml ... PROPERTY MAP_IMPORTED_CONFIG_DEBUG \" RELEASE\" )\n \n "
78
+ " Any app that statically links to Rust needs to use the release MSVC runtime for all components.\n "
79
+ " The following Qt components have been detected to link to the Debug runtime:\n "
80
+ " ${QT_COMPONENTS_DEBUG_MODE} \n \n "
81
+ " See also:\n "
82
+ " https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets\n "
83
+ " https://github.com/KDAB/cxx-qt/pull/683\n "
84
+ " https://github.com/KDAB/cxx-qt/issues/1234\n \n "
85
+ " To suppress this warning set CXX_QT_SUPPRESS_MSVC_RUNTIME_WARNING to ON"
86
+ )
87
+ endif ()
88
+ endif ()
64
89
endif ()
65
90
66
91
foreach (CRATE ${__cxx_qt_imported_crates} )
0 commit comments