diff options
| author | Arthur LAURENT <[email protected]> | 2024-02-04 18:58:36 +0100 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2024-02-04 18:59:51 +0100 |
| commit | b95ae652a0d72b3e3cd1ceefafb9e733282ca59d (patch) | |
| tree | d7a889fc0b03271d23354a897d7108645c929bfe | |
| parent | a914429dee256d88902bde6a7058bcaf81d0b629 (diff) | |
support --sdk for --runtimes
| -rw-r--r-- | xmake/modules/core/tools/clang.lua | 40 |
1 files changed, 24 insertions, 16 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua index 1a7f25d33..fe4641e77 100644 --- a/xmake/modules/core/tools/clang.lua +++ b/xmake/modules/core/tools/clang.lua @@ -243,14 +243,18 @@ function nf_runtime(self, runtime, opt) maps["c++_shared"] = "-stdlib=libc++" maps["stdc++_static"] = "-stdlib=libstdc++" maps["stdc++_shared"] = "-stdlib=libstdc++" - -- clang on windows fail to add libc++ includepath when using -stdlib=libc++ so we manually add it - -- @see https://github.com/llvm/llvm-project/issues/79647 - if self:is_plat("windows") then - local llvm_rootdir = _get_llvm_rootdir(self) - if llvm_rootdir then - maps["c++_static"] = table.join(maps["c++_static"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1")) - maps["c++_shared"] = table.join(maps["c++_shared"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1")) - end + local llvm_rootdir + if get_config("sdk") then + -- if a sdk dir is defined, we should redirect include path to have the correct includes + llvm_rootdir = get_config("sdk") + elseif self:is_plat("windows") then + -- clang on windows fail to add libc++ includepath when using -stdlib=libc++ so we manually add it + -- @see https://github.com/llvm/llvm-project/issues/79647 + llvm_rootdir = _get_llvm_rootdir(self) + end + if llvm_rootdir then + maps["c++_static"] = table.join(maps["c++_static"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1")) + maps["c++_shared"] = table.join(maps["c++_shared"], "-cxx-isystem" .. path.join(llvm_rootdir, "include", "c++", "v1")) end elseif kind == "ld" or kind == "sh" then local target = opt.target @@ -259,14 +263,18 @@ function nf_runtime(self, runtime, opt) maps["c++_shared"] = "-stdlib=libc++" maps["stdc++_static"] = "-stdlib=libstdc++" maps["stdc++_shared"] = "-stdlib=libstdc++" - -- clang on windows fail to add libc++ librarypath when using -stdlib=libc++ so we manually add it - -- @see https://github.com/llvm/llvm-project/issues/79647 - if self:is_plat("windows") then - local llvm_rootdir = _get_llvm_rootdir(self) - if llvm_rootdir then - maps["c++_static"] = table.join(maps["c++_static"], "-L" .. path.join(llvm_rootdir, "lib")) - maps["c++_shared"] = table.join(maps["c++_shared"], "-L" .. path.join(llvm_rootdir, "lib")) - end + local llvm_rootdir + if get_config("sdk") then + -- if a sdk dir is defined, we should redirect library path for linking the right libc++ + llvm_rootdir = get_config("sdk") + elseif self:is_plat("windows") then + -- clang on windows fail to add libc++ librarypath when using -stdlib=libc++ so we manually add it + -- @see https://github.com/llvm/llvm-project/issues/79647 + llvm_rootdir = _get_llvm_rootdir(self) + end + if llvm_rootdir then + maps["c++_static"] = table.join(maps["c++_static"], "-L" .. path.join(llvm_rootdir, "lib")) + maps["c++_shared"] = table.join(maps["c++_shared"], "-L" .. path.join(llvm_rootdir, "lib")) end if runtime:endswith("_static") and _has_static_libstdcxx(self) then maps["c++_static"] = table.join(maps["c++_static"], "-static-libstdc++") |
