From 4f49a9e1d57017620f62c600b2adf5a2ff48bb10 Mon Sep 17 00:00:00 2001 From: Chen Yufei Date: Wed, 23 Mar 2022 21:05:33 +0800 Subject: Enable PIC if only specifying toolchain. --- xmake/modules/package/tools/cmake.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index b5b47ced2..d6f882446 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -421,6 +421,10 @@ function _get_configs_for_cross(package, configs, opt) -- https://github.com/xmake-io/xmake/issues/2170 if not package:is_plat(os.subhost()) then envs.CMAKE_SYSTEM_NAME = "Linux" + else + if package:config("pic") ~= false then + table.insert(configs, "-DCMAKE_POSITION_INDEPENDENT_CODE=ON") + end end -- avoid find and add system include/library path -- @see https://github.com/xmake-io/xmake/issues/2037 -- cgit v1.3.1