summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-11-13 15:25:12 +0800
committerGitHub <[email protected]>2024-11-13 15:25:12 +0800
commit4fc4ffb51e5c346a4bce3d32b95584a58a75b553 (patch)
treebb239ca888f363986b0b4508c57c85b033a73e8e
parent52548a1ba3a1949d3cf36d5c019a1849e3e45d17 (diff)
parent37107f795f835fbd559b65edd486b5f6faf24226 (diff)
Merge pull request #5817 from xmake-io/pic
improve default pic for packages
-rw-r--r--xmake/modules/package/tools/autoconf.lua4
-rw-r--r--xmake/modules/package/tools/cmake.lua16
2 files changed, 9 insertions, 11 deletions
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index 9dc417c16..345b0fde9 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -162,7 +162,7 @@ function _get_configs(package, configs)
table.insert(configs, "--host=" .. host)
end
end
- if package:is_plat("linux", "bsd") and
+ if not package:is_plat("windows", "mingw") and
package:config("pic") ~= false and _has_with_pic(package) then
table.insert(configs, "--with-pic")
end
@@ -319,7 +319,7 @@ function buildenvs(package, opt)
envs.CPP = package:build_getenv("cpp")
envs.RANLIB = package:build_getenv("ranlib")
end
- if package:is_plat("linux", "bsd") and
+ if not package:is_plat("windows", "mingw") and
package:config("pic") ~= false and not _has_with_pic(package) then
table.insert(cflags, "-fPIC")
table.insert(cxxflags, "-fPIC")
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 7c3c52fd2..f0749bce0 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -420,7 +420,7 @@ function _get_configs_for_generic(package, configs, opt)
if shflags then
table.insert(configs, "-DCMAKE_SHARED_LINKER_FLAGS=" .. shflags)
end
- if package:config("pic") ~= false then
+ if not package:is_plat("windows", "mingw") and package:config("pic") ~= false then
table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
end
if not package:use_external_includes() then
@@ -661,10 +661,9 @@ function _get_configs_for_cross(package, configs, opt)
system_name = "Linux"
end
envs.CMAKE_SYSTEM_NAME = system_name
- else
- if package:config("pic") ~= false then
- table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
- end
+ end
+ if not package:is_plat("windows", "mingw") and package:config("pic") ~= false then
+ table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
end
-- avoid find and add system include/library path
-- @see https://github.com/xmake-io/xmake/issues/2037
@@ -716,10 +715,9 @@ function _get_configs_for_host_toolchain(package, configs, opt)
-- https://github.com/xmake-io/xmake/issues/2170
if package:is_cross() then
envs.CMAKE_SYSTEM_NAME = "Linux"
- else
- if package:config("pic") ~= false then
- table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
- end
+ end
+ if not package:is_plat("windows", "mingw") and package:config("pic") ~= false then
+ table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON")
end
_insert_configs_from_envs(configs, envs, opt)
end