diff options
| author | star9029 <[email protected]> | 2024-08-29 23:43:35 +0800 |
|---|---|---|
| committer | star9029 <[email protected]> | 2024-08-29 23:43:35 +0800 |
| commit | 3ee57aa5c9297e37027108fd1756f93eef9da196 (patch) | |
| tree | 6722e8a381a5a8a71f290403e69a4388bbe39b0e | |
| parent | 7d2b49214caa15642cbdff28bf8797692e14768c (diff) | |
improve cmake configure
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 2dabe8b86..f7556dd8e 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -1171,14 +1171,9 @@ function _get_cmake_generator(package, opt) return cmake_generator end -function configure(package, configs, opt) +function configure(package, configs, opt, sourcedir) opt = opt or {} - -- enter build directory - local buildir = opt.buildir or package:buildir() - os.mkdir(path.join(buildir, "install")) - local oldir = os.cd(buildir) - -- pass configurations local argv = {} for name, value in pairs(_get_configs(package, configs, opt)) do @@ -1191,20 +1186,23 @@ function configure(package, configs, opt) table.insert(argv, "-D" .. name .. "=" .. value) end end - table.insert(argv, oldir) + table.insert(argv, sourcedir) -- do configure local cmake = assert(find_tool("cmake"), "cmake not found!") os.vrunv(cmake.program, argv, {envs = opt.envs or buildenvs(package, opt)}) - - return oldir end -- build package function build(package, configs, opt) opt = opt or {} local cmake_generator = _get_cmake_generator(package, opt) - local oldir = configure(package, configs, opt) + + -- enter build directory + local buildir = opt.buildir or package:buildir() + os.mkdir(path.join(buildir, "install")) + local oldir = os.cd(buildir) + configure(package, configs, opt, oldir) -- do build if opt.cmake_build then @@ -1233,7 +1231,12 @@ end function install(package, configs, opt) opt = opt or {} local cmake_generator = _get_cmake_generator(package, opt) - local oldir = configure(package, configs, opt) + + -- enter build directory + local buildir = opt.buildir or package:buildir() + os.mkdir(path.join(buildir, "install")) + local oldir = os.cd(buildir) + configure(package, configs, opt, oldir) -- do build and install if opt.cmake_build then |
