summaryrefslogtreecommitdiff
path: root/xmake/modules/package/tools/cmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-11-20 23:18:07 +0800
committerruki <[email protected]>2020-11-20 23:18:07 +0800
commit67c8c8d3c99912e360220ad0477de40d100be552 (patch)
treed3f696dd267d6b70f36b20b148bb164428223925 /xmake/modules/package/tools/cmake.lua
parentb5ffa09e27f191df0a3853876131901c13d26b9b (diff)
improve tools/cmake for ninja generator
Diffstat (limited to 'xmake/modules/package/tools/cmake.lua')
-rw-r--r--xmake/modules/package/tools/cmake.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 453097c6d..3f8cd19e3 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -252,8 +252,18 @@ function _get_configs(package, configs, opt)
end
-- get build environments
-function buildenvs(package)
- local envs = {}
+function buildenvs(package, opt)
+
+ -- use ninja generator for windows platform? we need bind msvc environments manually
+ -- @see https://github.com/xmake-io/xmake/issues/1057
+ opt = opt or {}
+ local envs = {}
+ local cmake_generator = opt.cmake_generator
+ if cmake_generator and cmake_generator == "Ninja" and package:is_plat("windows") then
+ table.join2(envs, toolchain.load("msvc"):runenvs())
+ end
+
+ -- add environments for cmake/find_packages
local CMAKE_LIBRARY_PATH = {}
local CMAKE_INCLUDE_PATH = {}
local CMAKE_PREFIX_PATH = {}
@@ -439,7 +449,7 @@ function build(package, configs, opt)
table.insert(argv, '..')
-- do configure
- os.vrunv("cmake", argv, {envs = opt.envs or buildenvs(package)})
+ os.vrunv("cmake", argv, {envs = opt.envs or buildenvs(package, opt)})
-- do build
local cmake_generator = opt.cmake_generator
@@ -497,7 +507,7 @@ function install(package, configs, opt)
table.insert(argv, '..')
-- generate build file
- os.vrunv("cmake", argv, {envs = opt.envs or buildenvs(package)})
+ os.vrunv("cmake", argv, {envs = opt.envs or buildenvs(package, opt)})
-- do build and install
local cmake_generator = opt.cmake_generator