summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-07-11 19:52:44 +0800
committerGitHub <noreply@github.com>2024-07-11 19:52:44 +0800
commit57742cb02b04ea973ff702b42a7e380decd4048f (patch)
tree7d9442161f76e91e66ddb108002d5b84b980cddf
parent304f9f9a355ba543c767094c17f147e3845065fa (diff)
Statically link MSVC runtime (#4613)
* Statically link MSVC runtime * Statically link MSVC runtime for llvm
-rw-r--r--CMakeLists.txt1
-rw-r--r--CMakePresets.json5
-rwxr-xr-xexternal/build-llvm.sh4
3 files changed, 9 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 415343050..1dd289a8d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.25")
cmake_policy(SET CMP0141 NEW)
endif()
+cmake_policy(SET CMP0091 NEW)
# Don't use absolute paths to the build tree in RPATH, this makes the build
# tree relocatable
diff --git a/CMakePresets.json b/CMakePresets.json
index 7e0697afb..08f85a37f 100644
--- a/CMakePresets.json
+++ b/CMakePresets.json
@@ -10,7 +10,10 @@
"name": "default",
"description": "Default build using Ninja Multi-Config generator",
"generator": "Ninja Multi-Config",
- "binaryDir": "${sourceDir}/build"
+ "binaryDir": "${sourceDir}/build",
+ "cacheVariables": {
+ "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>"
+ }
},
{
"name": "msvc-base",
diff --git a/external/build-llvm.sh b/external/build-llvm.sh
index 142d30ee2..95302a742 100755
--- a/external/build-llvm.sh
+++ b/external/build-llvm.sh
@@ -109,6 +109,10 @@ cmake_arguments_for_slang=(
-DLLVM_ENABLE_PROJECTS=clang
"-DLLVM_TARGETS_TO_BUILD=X86;ARM;AArch64"
-DLLVM_BUILD_TOOLS=0
+ # Get LLVM to use the static linked version of the msvc runtime
+ "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>"
+ "-DLLVM_USE_CRT_RELEASE=MT"
+ "-DLLVM_USE_CRT_DEBUG=MTd"
)
build_dir=$source_dir/build
mkdir -p "$build_dir"