From 6996d90e429ff6013d31ffb98601fa006f07b650 Mon Sep 17 00:00:00 2001 From: RichardYCJ Date: Sat, 11 Mar 2023 11:30:24 +0800 Subject: improve cmake::find_package, use debug flags --- xmake/modules/package/manager/cmake/configurations.lua | 1 + xmake/modules/package/manager/cmake/find_package.lua | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/xmake/modules/package/manager/cmake/configurations.lua b/xmake/modules/package/manager/cmake/configurations.lua index 3cc597a93..626c973d0 100644 --- a/xmake/modules/package/manager/cmake/configurations.lua +++ b/xmake/modules/package/manager/cmake/configurations.lua @@ -29,6 +29,7 @@ function main() moduledirs = {description = "Set the cmake modules directories."}, presets = {description = "Set the preset values, e.g. {Boost_USE_STATIC_LIB = true}"}, envs = {description = "Set the run environments of cmake, e.g. {CMAKE_PREFIX_PATH = \"xxx\"}"}, + debug = {description = "Set the CMAKE_BUILD_TYPE=Debug if set to ture."} } end diff --git a/xmake/modules/package/manager/cmake/find_package.lua b/xmake/modules/package/manager/cmake/find_package.lua index 9548f9d76..a25cd9e74 100644 --- a/xmake/modules/package/manager/cmake/find_package.lua +++ b/xmake/modules/package/manager/cmake/find_package.lua @@ -107,6 +107,13 @@ function _find_package(cmake, name, opt) -- run cmake local envs = configs.envs or opt.envs + if (configs.debug) then + if (not envs) then + envs = {CMAKE_BUILD_TYPE = "Debug"} + elseif (not envs.CMAKE_BUILD_TYPE) then + envs.CMAKE_BUILD_TYPE = "Debug" + end + end try {function() return os.vrunv(cmake.program, {workdir}, {curdir = workdir, envs = envs}) end} -- pares defines and includedirs for macosx/linux -- cgit v1.3.1