summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-05-06 17:34:47 +0200
committerArthur LAURENT <[email protected]>2025-05-06 17:34:47 +0200
commitfe7061037c46ab919766dfc8318f4deda22a1410 (patch)
treebf34b6ca065e1a448a6236b6a2bf08f030c33ca1
parenta4d1b8c7ee7caa4d48ce8182e948e5058c005ec0 (diff)
(packages) forward buildtype and library kind to underlying buildsystem (cmake, autotools)
-rw-r--r--xmake/modules/package/tools/autoconf.lua55
-rw-r--r--xmake/modules/package/tools/cmake.lua5
2 files changed, 51 insertions, 9 deletions
diff --git a/xmake/modules/package/tools/autoconf.lua b/xmake/modules/package/tools/autoconf.lua
index 5a287045f..b9339fcb7 100644
--- a/xmake/modules/package/tools/autoconf.lua
+++ b/xmake/modules/package/tools/autoconf.lua
@@ -86,18 +86,40 @@ function _memcache()
return memcache.cache("package.tools.autoconf")
end
--- has `--with-pic`?
-function _has_with_pic(package)
- local has_with_pic = _memcache():get2(tostring(package), "with_pic")
- if has_with_pic == nil then
+-- has flag ?
+function _has_flag(package, flag)
+ local flag_name = flag:gsub("-", "")
+ local has_flag = _memcache():get2(tostring(package), flag_name)
+ if has_flag == nil then
local result = try {function() return os.iorunv("./configure", {"--help"}, {shell = true}) end}
- if result and result:find("--with-pic", 1, true) then
- has_with_pic = true
+ if result and result:find(flag, 1, true) then
+ has_flag = true
end
- has_with_pic = has_with_pic or false
- _memcache():set2(tostring(package), "with_pic", has_with_pic)
+ has_flag = has_flag or false
+ _memcache():set2(tostring(package), flag_name, has_flag)
end
- return has_with_pic
+ return has_flag
+end
+
+
+-- has `--with-pic`?
+function _has_with_pic(package)
+ return _has_flag(package, "--with-pic")
+end
+
+-- has `--enable-debug`?
+function _has_enable_debug(package)
+ return _has_flag(package, "--enable-debug")
+end
+
+-- has `--enable-static` and `--enable-shared`?
+function _has_enable_kind(package)
+ return _has_flag(package, "--enable-static") and _has_flag(package, "--enable-shared")
+end
+
+-- has `--disable-static` and `--disable-shared`?
+function _has_disable_kind(package)
+ return _has_flag(package, "--disable-static") and _has_flag(package, "--disable-shared")
end
-- get configs
@@ -170,6 +192,21 @@ function _get_configs(package, configs)
package:config("pic") ~= false and _has_with_pic(package) then
table.insert(configs, "--with-pic")
end
+ if package:is_debug() and _has_enable_debug(package) then
+ table.insert(configs, "--enable-debug")
+ end
+ if package:is_library() then
+ if _has_enable_kind(package) then
+ table.insert(configs, "--enable-shared=" .. (package:config("shared") and "yes" or "no"))
+ table.insert(configs, "--enable-static=" .. (package:config("shared") and "no" or "yes"))
+ elseif _has_disable_kind(package) then
+ if package:config("shared") then
+ table.insert(configs, "--disable-static")
+ else
+ table.insert(configs, "--disable-shared")
+ end
+ end
+ end
return configs
end
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 64f7bea3a..a674e9433 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -427,6 +427,11 @@ function _get_configs_for_generic(package, configs, opt)
if not package:use_external_includes() then
table.insert(configs, "-DCMAKE_NO_SYSTEM_FROM_IMPORTED=ON")
end
+ if package:is_debug() then
+ table.insert(configs, "-DCMAKE_BUILD_TYPE=Debug")
+ else
+ table.insert(configs, "-DCMAKE_BUILD_TYPE=Release")
+ end
end
-- get configs for windows