diff options
| author | ruki <[email protected]> | 2024-11-13 23:20:09 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-11-13 23:20:09 +0800 |
| commit | 37107f795f835fbd559b65edd486b5f6faf24226 (patch) | |
| tree | 6540ef3839da5b136f893bdfed1ced8f2e575473 | |
| parent | 3b4a8beb71f7ebce1b1e83ff4c6bd10e02ce928b (diff) | |
improve default pic for packages
| -rw-r--r-- | xmake/modules/package/tools/autoconf.lua | 4 | ||||
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 16 |
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 |
