Skip to content

Commit e1f3dc9

Browse files
authored
Merge pull request #5115 from xmake-io/cmake
fix cmake default flags
2 parents e4d9f10 + f97b88e commit e1f3dc9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

xmake/modules/package/tools/cmake.lua

+6-3
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,10 @@ function _get_configs_for_install(package, configs, opt)
724724
end
725725

726726
function _get_default_flags(package, configs, buildtype, opt)
727-
local cmake_default_flags = _g.cmake_default_flags and _g.cmake_default_flags[buildtype]
727+
-- The default flags are different for different platforms
728+
-- @see https://github.com/xmake-io/xmake-repo/pull/4038#issuecomment-2116489448
729+
local cachekey = buildtype .. package:plat() .. package:arch()
730+
local cmake_default_flags = _g.cmake_default_flags and _g.cmake_default_flags[cachekey]
728731
if not cmake_default_flags then
729732
local tmpdir = path.join(os.tmpdir() .. ".dir", package:name(), package:mode())
730733
local dummy_cmakelist = path.join(tmpdir, "CMakeLists.txt")
@@ -764,7 +767,7 @@ function _get_default_flags(package, configs, buildtype, opt)
764767
cmake_default_flags.arflags = cmake_default_flags.arflags .. " " ..outdata:match(format("CMAKE_STATIC_LINKER_FLAGS_%s is (.-)\n", buildtype))
765768

766769
_g.cmake_default_flags = _g.cmake_default_flags or {}
767-
_g.cmake_default_flags[buildtype] = cmake_default_flags
770+
_g.cmake_default_flags[cachekey] = cmake_default_flags
768771
end
769772
os.rm(tmpdir)
770773
end
@@ -822,7 +825,7 @@ function _get_envs_for_runtime_flags(package, configs, opt)
822825
end
823826
return envs
824827
end
825-
-- get configs
828+
826829
function _get_configs(package, configs, opt)
827830
configs = configs or {}
828831
opt._configs_str = string.serialize(configs, {indent = false, strip = true})

0 commit comments

Comments
 (0)