Skip to content

Commit

Permalink
Statically link MSVC runtime (#4613)
Browse files Browse the repository at this point in the history
* Statically link MSVC runtime

* Statically link MSVC runtime for llvm
  • Loading branch information
expipiplus1 authored Jul 11, 2024
1 parent 304f9f9 commit 57742cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 4 additions & 0 deletions external/build-llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 57742cb

Please sign in to comment.