summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-07-02 21:29:01 +0800
committerruki <[email protected]>2023-07-02 21:29:01 +0800
commit5b203fc91970a74ec2d7c73ae04c3b666b89924f (patch)
treea1a5e762d7c41a009ef8776debafc89de0251c01
parent95df1f53c56d12b940e04b326ee05e090e3fed1a (diff)
fix tools.cmake for cross compilation #3913
-rw-r--r--xmake/modules/package/tools/cmake.lua7
1 files changed, 6 insertions, 1 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index d8b4a7a6f..6daf89491 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -558,7 +558,12 @@ function _get_configs_for_host_toolchain(package, configs, opt)
name = name:gsub("clang%-", "clang++-")
name = name:gsub("gcc$", "g++")
name = name:gsub("gcc%-", "g++-")
- envs.CMAKE_CXX_COMPILER = _translate_bin_path(dir and path.join(dir, name) or name)
+ if dir and dir ~= "." then
+ cxx = path.join(dir, name)
+ else
+ cxx = name
+ end
+ envs.CMAKE_CXX_COMPILER = _translate_bin_path(cxx)
end
-- @note The link command line is set in Modules/CMake{C,CXX,Fortran}Information.cmake and defaults to using the compiler, not CMAKE_LINKER,
-- so we need set CMAKE_CXX_LINK_EXECUTABLE to use CMAKE_LINKER as linker.