Skip to content

fix cmake default flags #5115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,10 @@ function _get_configs_for_install(package, configs, opt)
end

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

_g.cmake_default_flags = _g.cmake_default_flags or {}
_g.cmake_default_flags[buildtype] = cmake_default_flags
_g.cmake_default_flags[cachekey] = cmake_default_flags
end
os.rm(tmpdir)
end
Expand Down Expand Up @@ -822,7 +825,7 @@ function _get_envs_for_runtime_flags(package, configs, opt)
end
return envs
end
-- get configs

function _get_configs(package, configs, opt)
configs = configs or {}
opt._configs_str = string.serialize(configs, {indent = false, strip = true})
Expand Down
Loading