Skip to content

Commit 90b47a2

Browse files
authored
Merge pull request #6846 from xmake-io/cmake
improve cmake default flags #6845
2 parents bf90656 + 4700738 commit 90b47a2

File tree

1 file changed

+2
-26
lines changed

1 file changed

+2
-26
lines changed

xmake/modules/package/tools/cmake.lua

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -848,31 +848,7 @@ end
848848

849849
function _get_envs_for_default_flags(package, configs, opt)
850850
local buildtype = _get_cmake_buildtype(package)
851-
local envs = {}
852-
local default_flags = _get_default_flags(package, configs, buildtype, opt)
853-
if default_flags then
854-
if not opt.cxxflags and not opt.cxflags then
855-
envs.CMAKE_CXX_FLAGS = default_flags.CMAKE_CXX_FLAGS
856-
envs["CMAKE_CXX_FLAGS_" .. buildtype] = default_flags["CMAKE_CXX_FLAGS_" .. buildtype]
857-
end
858-
if not opt.cflags and not opt.cxflags then
859-
envs.CMAKE_C_FLAGS = default_flags.CMAKE_C_FLAGS
860-
envs["CMAKE_C_FLAGS_" .. buildtype] = default_flags["CMAKE_C_FLAGS_" .. buildtype]
861-
end
862-
if not opt.ldflags then
863-
envs.CMAKE_EXE_LINKER_FLAGS = default_flags.CMAKE_EXE_LINKER_FLAGS
864-
envs["CMAKE_EXE_LINKER_FLAGS_" .. buildtype] = default_flags["CMAKE_EXE_LINKER_FLAGS_" .. buildtype]
865-
end
866-
if not opt.arflags then
867-
envs.CMAKE_STATIC_LINKER_FLAGS = default_flags.CMAKE_STATIC_LINKER_FLAGS
868-
envs["CMAKE_STATIC_LINKER_FLAGS_" .. buildtype] = default_flags["CMAKE_STATIC_LINKER_FLAGS_" .. buildtype]
869-
end
870-
if not opt.shflags then
871-
envs.CMAKE_SHARED_LINKER_FLAGS = default_flags.CMAKE_SHARED_LINKER_FLAGS
872-
envs["CMAKE_SHARED_LINKER_FLAGS_" .. buildtype] = default_flags["CMAKE_SHARED_LINKER_FLAGS_" .. buildtype]
873-
end
874-
end
875-
return envs
851+
return table.clone(_get_default_flags(package, configs, buildtype, opt)) or {}
876852
end
877853

878854
function _get_envs_for_runtime_flags(package, opt)
@@ -892,7 +868,7 @@ end
892868

893869
function _get_envs_for_flags(package, configs, opt)
894870
-- get the default envs
895-
local envs = _get_envs_for_default_flags(package, configs, opt) or {}
871+
local envs = _get_envs_for_default_flags(package, configs, opt)
896872
local runtime_envs = _get_envs_for_runtime_flags(package, opt)
897873
if runtime_envs then
898874
for name, value in pairs(runtime_envs) do

0 commit comments

Comments
 (0)