From 60ebf1c653664ecb409f790038bdead8b47ae3d4 Mon Sep 17 00:00:00 2001 From: Andrew Hayzen Date: Wed, 6 Sep 2023 11:40:31 +0100 Subject: [PATCH] cmake: set MSVC_RUNTIME_LIBRARY to MultiThreadedDLL As Rust always uses the non-debug Windows runtime for MSVC targets. Related to #682 Related to #676 --- examples/demo_threading/CMakeLists.txt | 7 +++++++ examples/qml_features/CMakeLists.txt | 7 +++++++ examples/qml_minimal/CMakeLists.txt | 7 +++++++ tests/basic_cxx_only/CMakeLists.txt | 7 +++++++ tests/basic_cxx_qt/CMakeLists.txt | 7 +++++++ tests/qt_types_standalone/CMakeLists.txt | 7 +++++++ 6 files changed, 42 insertions(+) diff --git a/examples/demo_threading/CMakeLists.txt b/examples/demo_threading/CMakeLists.txt index 138ea4e02..90d0515e2 100644 --- a/examples/demo_threading/CMakeLists.txt +++ b/examples/demo_threading/CMakeLists.txt @@ -8,6 +8,13 @@ cmake_minimum_required(VERSION 3.24) project(demo_threading) set(APP_NAME ${PROJECT_NAME}) +# Rust always links against non-debug Windows runtime on *-msvc targets +# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets +# https://github.com/rust-lang/rust/issues/39016 +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) diff --git a/examples/qml_features/CMakeLists.txt b/examples/qml_features/CMakeLists.txt index 64b1ae3e9..8e07aa0bf 100644 --- a/examples/qml_features/CMakeLists.txt +++ b/examples/qml_features/CMakeLists.txt @@ -9,6 +9,13 @@ cmake_minimum_required(VERSION 3.24) project(example_qml_features) set(APP_NAME ${PROJECT_NAME}) +# Rust always links against non-debug Windows runtime on *-msvc targets +# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets +# https://github.com/rust-lang/rust/issues/39016 +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) diff --git a/examples/qml_minimal/CMakeLists.txt b/examples/qml_minimal/CMakeLists.txt index 04e3363a7..cea5e196c 100644 --- a/examples/qml_minimal/CMakeLists.txt +++ b/examples/qml_minimal/CMakeLists.txt @@ -10,6 +10,13 @@ cmake_minimum_required(VERSION 3.24) project(example_qml_minimal) set(APP_NAME ${PROJECT_NAME}) +# Rust always links against non-debug Windows runtime on *-msvc targets +# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets +# https://github.com/rust-lang/rust/issues/39016 +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + set(CMAKE_AUTOMOC ON) set(CMAKE_AUTORCC ON) set(CMAKE_CXX_STANDARD 17) diff --git a/tests/basic_cxx_only/CMakeLists.txt b/tests/basic_cxx_only/CMakeLists.txt index a3f3be1c8..e2ab172ce 100644 --- a/tests/basic_cxx_only/CMakeLists.txt +++ b/tests/basic_cxx_only/CMakeLists.txt @@ -9,6 +9,13 @@ cmake_minimum_required(VERSION 3.24) project(tests_basic_cxx_only) set(APP_NAME ${PROJECT_NAME}) +# Rust always links against non-debug Windows runtime on *-msvc targets +# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets +# https://github.com/rust-lang/rust/issues/39016 +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + # TODO: Add a helper function to our CMake module which automatically # handles some of this boilerplate for a "typical" Qt application set(CMAKE_AUTOMOC ON) diff --git a/tests/basic_cxx_qt/CMakeLists.txt b/tests/basic_cxx_qt/CMakeLists.txt index 252679763..dda76a370 100644 --- a/tests/basic_cxx_qt/CMakeLists.txt +++ b/tests/basic_cxx_qt/CMakeLists.txt @@ -9,6 +9,13 @@ cmake_minimum_required(VERSION 3.24) project(tests_basic_cxx_qt) set(APP_NAME ${PROJECT_NAME}) +# Rust always links against non-debug Windows runtime on *-msvc targets +# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets +# https://github.com/rust-lang/rust/issues/39016 +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + # TODO: Add a helper function to our CMake module which automatically # handles some of this boilerplate for a "typical" Qt application set(CMAKE_AUTOMOC ON) diff --git a/tests/qt_types_standalone/CMakeLists.txt b/tests/qt_types_standalone/CMakeLists.txt index 2dd07d8ee..1da325838 100644 --- a/tests/qt_types_standalone/CMakeLists.txt +++ b/tests/qt_types_standalone/CMakeLists.txt @@ -9,6 +9,13 @@ cmake_minimum_required(VERSION 3.24) project(tests_qt_types_standalone) set(APP_NAME ${PROJECT_NAME}) +# Rust always links against non-debug Windows runtime on *-msvc targets +# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets +# https://github.com/rust-lang/rust/issues/39016 +if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + # TODO: Add a helper function to our CMake module which automatically # handles some of this boilerplate for a "typical" Qt application set(CMAKE_AUTOMOC ON)