Skip to content

Commit

Permalink
Merge pull request #5817 from xmake-io/pic
Browse files Browse the repository at this point in the history
improve default pic for packages
  • Loading branch information
waruqi authored Nov 13, 2024
2 parents 52548a1 + 37107f7 commit 4fc4ffb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions xmake/modules/package/tools/autoconf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
16 changes: 7 additions & 9 deletions xmake/modules/package/tools/cmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4fc4ffb

Please sign in to comment.