diff options
| author | ruki <[email protected]> | 2021-04-11 00:01:36 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-04-11 00:01:36 +0800 |
| commit | ec1735efd25891c14e488097cfb7f9d12933bbbe (patch) | |
| tree | a83cfc4ec3ae3148328c146b8d93e6a552f87d9a /xmake/modules/package/tools/cmake.lua | |
| parent | e5c1550e47018a1e6545197d2e5364c15ed56678 (diff) | |
improve tools/cmake
Diffstat (limited to 'xmake/modules/package/tools/cmake.lua')
| -rw-r--r-- | xmake/modules/package/tools/cmake.lua | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua index 6281372f9..8c9584145 100644 --- a/xmake/modules/package/tools/cmake.lua +++ b/xmake/modules/package/tools/cmake.lua @@ -425,9 +425,22 @@ function _get_configs_for_generator(package, configs, opt) end end +-- get configs for installation +function _get_configs_for_install(package, configs, opt) + -- @see https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html + -- LIBDIR: object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian) + -- + table.insert(configs, "-DCMAKE_INSTALL_PREFIX=" .. path.absolute("install")) + if not opt._configs_str:find("CMAKE_INSTALL_LIBDIR") then + table.insert(configs, "-DCMAKE_INSTALL_LIBDIR=" .. path.absolute("install/lib")) + end +end + -- get configs function _get_configs(package, configs, opt) configs = configs or {} + opt._configs_str = string.serialize(configs, {indent = false, strip = true}) + _get_configs_for_install(package, configs, opt) _get_configs_for_generator(package, configs, opt) if package:is_plat("windows") then _get_configs_for_windows(package, configs, opt) @@ -605,13 +618,6 @@ function build(package, configs, opt) os.mkdir(path.join(buildir, "install")) local oldir = os.cd(buildir) - -- init arguments - -- - -- @see https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html - -- LIBDIR: object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian) - -- - local argv = {"-DCMAKE_INSTALL_PREFIX=" .. path.absolute("install"), "-DCMAKE_INSTALL_LIBDIR=" .. path.absolute("install/lib")} - -- exists $CMAKE_GENERATOR? use it local cmake_generator_env = os.getenv("CMAKE_GENERATOR") if not opt.cmake_generator and cmake_generator_env then @@ -619,6 +625,7 @@ function build(package, configs, opt) end -- pass configurations + local argv = {} for name, value in pairs(_get_configs(package, configs, opt)) do value = tostring(value):trim() if type(name) == "number" then @@ -626,7 +633,7 @@ function build(package, configs, opt) table.insert(argv, value) end else - table.insert(argv, "--" .. name .. "=" .. value) + table.insert(argv, "-D" .. name .. "=" .. value) end end table.insert(argv, oldir) @@ -670,14 +677,8 @@ function install(package, configs, opt) os.mkdir(path.join(buildir, "install")) local oldir = os.cd(buildir) - -- init arguments - -- - -- @see https://cmake.org/cmake/help/v3.14/module/GNUInstallDirs.html - -- LIBDIR: object code libraries (lib or lib64 or lib/<multiarch-tuple> on Debian) - -- - local argv = {"-DCMAKE_INSTALL_PREFIX=" .. path.absolute("install"), "-DCMAKE_INSTALL_LIBDIR=" .. path.absolute("install/lib")} - -- pass configurations + local argv = {} for name, value in pairs(_get_configs(package, configs, opt)) do value = tostring(value):trim() if type(name) == "number" then @@ -685,7 +686,7 @@ function install(package, configs, opt) table.insert(argv, value) end else - table.insert(argv, "--" .. name .. "=" .. value) + table.insert(argv, "-D" .. name .. "=" .. value) end end table.insert(argv, oldir) |
