Skip to content

Commit 8f550ca

Browse files
committed
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
1 parent 3877623 commit 8f550ca

File tree

7 files changed

+49
-0
lines changed

7 files changed

+49
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4848

4949
- Do not use -bundle otherwise CMake builds are missing qt-static-initalizers (note this is broken in rustc 1.69)
5050
- Do not import `Pin` in hidden module as invokables are outside now, resolving IDE integration
51+
- Rust always links against a non-debug Windows runtime with *-msvc targets, so we need to link to MultiThreadedDLL
5152

5253
### Removed
5354

examples/demo_threading/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ cmake_minimum_required(VERSION 3.24)
88
project(demo_threading)
99
set(APP_NAME ${PROJECT_NAME})
1010

11+
# Rust always links against non-debug Windows runtime on *-msvc targets
12+
# Note it is best to set this on the command line to ensure all targets are consistent
13+
# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets
14+
# https://github.com/rust-lang/rust/issues/39016
15+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
16+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
17+
endif()
18+
1119
set(CMAKE_AUTOMOC ON)
1220
set(CMAKE_AUTORCC ON)
1321
set(CMAKE_CXX_STANDARD 17)

examples/qml_features/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ cmake_minimum_required(VERSION 3.24)
99
project(example_qml_features)
1010
set(APP_NAME ${PROJECT_NAME})
1111

12+
# Rust always links against non-debug Windows runtime on *-msvc targets
13+
# Note it is best to set this on the command line to ensure all targets are consistent
14+
# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets
15+
# https://github.com/rust-lang/rust/issues/39016
16+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
17+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
18+
endif()
19+
1220
set(CMAKE_AUTOMOC ON)
1321
set(CMAKE_AUTORCC ON)
1422
set(CMAKE_CXX_STANDARD 17)

examples/qml_minimal/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ cmake_minimum_required(VERSION 3.24)
1010
project(example_qml_minimal)
1111
set(APP_NAME ${PROJECT_NAME})
1212

13+
# Rust always links against non-debug Windows runtime on *-msvc targets
14+
# Note it is best to set this on the command line to ensure all targets are consistent
15+
# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets
16+
# https://github.com/rust-lang/rust/issues/39016
17+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
18+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
19+
endif()
20+
1321
set(CMAKE_AUTOMOC ON)
1422
set(CMAKE_AUTORCC ON)
1523
set(CMAKE_CXX_STANDARD 17)

tests/basic_cxx_only/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ cmake_minimum_required(VERSION 3.24)
99
project(tests_basic_cxx_only)
1010
set(APP_NAME ${PROJECT_NAME})
1111

12+
# Rust always links against non-debug Windows runtime on *-msvc targets
13+
# Note it is best to set this on the command line to ensure all targets are consistent
14+
# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets
15+
# https://github.com/rust-lang/rust/issues/39016
16+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
17+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
18+
endif()
19+
1220
# TODO: Add a helper function to our CMake module which automatically
1321
# handles some of this boilerplate for a "typical" Qt application
1422
set(CMAKE_AUTOMOC ON)

tests/basic_cxx_qt/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ cmake_minimum_required(VERSION 3.24)
99
project(tests_basic_cxx_qt)
1010
set(APP_NAME ${PROJECT_NAME})
1111

12+
# Rust always links against non-debug Windows runtime on *-msvc targets
13+
# Note it is best to set this on the command line to ensure all targets are consistent
14+
# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets
15+
# https://github.com/rust-lang/rust/issues/39016
16+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
17+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
18+
endif()
19+
1220
# TODO: Add a helper function to our CMake module which automatically
1321
# handles some of this boilerplate for a "typical" Qt application
1422
set(CMAKE_AUTOMOC ON)

tests/qt_types_standalone/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ cmake_minimum_required(VERSION 3.24)
99
project(tests_qt_types_standalone)
1010
set(APP_NAME ${PROJECT_NAME})
1111

12+
# Rust always links against non-debug Windows runtime on *-msvc targets
13+
# Note it is best to set this on the command line to ensure all targets are consistent
14+
# https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets
15+
# https://github.com/rust-lang/rust/issues/39016
16+
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
17+
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
18+
endif()
19+
1220
# TODO: Add a helper function to our CMake module which automatically
1321
# handles some of this boilerplate for a "typical" Qt application
1422
set(CMAKE_AUTOMOC ON)

0 commit comments

Comments
 (0)