summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-09-07 23:11:23 +0800
committerruki <[email protected]>2020-09-07 23:11:23 +0800
commita60e3691be27ed3f5a0d7651f7b720b7e75b7031 (patch)
treea7c40369f4c0ef8ac132fa351634ff6ce2a09620
parent84085d03b29fcb17ef93f6e8e367b21488904f6e (diff)
support ios for trybuild/cmake
-rw-r--r--CHANGELOG.md4
-rw-r--r--xmake/modules/package/tools/cmake.lua15
-rw-r--r--xmake/modules/private/action/trybuild/cmake.lua29
3 files changed, 34 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9b4cb7e10..7cd864131 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,7 +19,7 @@
* [#931](https://github.com/xmake-io/xmake/issues/931): Support to export packages with all dependences
* [#930](https://github.com/xmake-io/xmake/issues/930): Support to download package without version list directly
* [#927](https://github.com/xmake-io/xmake/issues/927): Support to switch arm/thumb mode for android ndk
-* Improve trybuild/cmake to support android toolchain
+* Improve trybuild/cmake to support android/mingw/iphoneos/watchos toolchains
### Bugs fixed
@@ -830,7 +830,7 @@
* [#931](https://github.com/xmake-io/xmake/issues/931): 改进导出包,支持导出所有依赖包
* [#930](https://github.com/xmake-io/xmake/issues/930): 如果私有包定义没有版本定义,支持直接尝试下载包
* [#927](https://github.com/xmake-io/xmake/issues/927): 改进android ndk,支持arm/thumb指令模式切换
-* 改进 trybuild/cmake 支持 Android 工具链
+* 改进 trybuild/cmake 支持 Android/Mingw/iPhoneOS/WatchOS 工具链
### Bugs修复
diff --git a/xmake/modules/package/tools/cmake.lua b/xmake/modules/package/tools/cmake.lua
index 81df10d5d..28a767ad3 100644
--- a/xmake/modules/package/tools/cmake.lua
+++ b/xmake/modules/package/tools/cmake.lua
@@ -58,8 +58,8 @@ function _get_configs_for_android(package, configs)
end
end
--- get configs for iphoneos
-function _get_configs_for_iphoneos(package, configs)
+-- get configs for appleos
+function _get_configs_for_appleos(package, configs)
local envs = {}
local cflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cflags"))
local cxxflags = table.join(table.wrap(package:build_getenv("cxflags")), package:build_getenv("cxxflags"))
@@ -69,9 +69,16 @@ function _get_configs_for_iphoneos(package, configs)
envs.CMAKE_STATIC_LINKER_FLAGS = table.concat(table.wrap(package:build_getenv("arflags")), ' ')
envs.CMAKE_EXE_LINKER_FLAGS = table.concat(table.wrap(package:build_getenv("ldflags")), ' ')
envs.CMAKE_SHARED_LINKER_FLAGS = table.concat(table.wrap(package:build_getenv("shflags")), ' ')
+ if package:is_plat("watchos") then
+ envs.CMAKE_SYSTEM_NAME = "watchOS"
+ else
+ envs.CMAKE_SYSTEM_NAME = "iOS"
+ end
envs.CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = "ONLY"
envs.CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = "ONLY"
envs.CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "NEVER"
+ -- avoid install bundle targets
+ envs.CMAKE_MACOSX_BUNDLE = "NO"
for k, v in pairs(envs) do
table.insert(configs, "-D" .. k .. "=" .. v)
end
@@ -152,8 +159,8 @@ function _get_configs(package, configs)
_get_configs_for_windows(package, configs)
elseif package:is_plat("android") then
_get_configs_for_android(package, configs)
- elseif package:is_plat("iphoneos") then
- _get_configs_for_iphoneos(package, configs)
+ elseif package:is_plat("iphoneos", "watchos") then
+ _get_configs_for_appleos(package, configs)
elseif package:is_plat("mingw") then
_get_configs_for_mingw(package, configs)
elseif not package:is_plat(os.subhost()) then
diff --git a/xmake/modules/private/action/trybuild/cmake.lua b/xmake/modules/private/action/trybuild/cmake.lua
index 0fba5281f..d08824cda 100644
--- a/xmake/modules/private/action/trybuild/cmake.lua
+++ b/xmake/modules/private/action/trybuild/cmake.lua
@@ -49,6 +49,14 @@ function _get_buildenv(key)
return value
end
+-- get configs for windows
+function _get_configs_for_windows(configs)
+ if is_arch("x64") then
+ table.insert(configs, "-A")
+ table.insert(configs, "x64")
+ end
+end
+
-- get configs for android
function _get_configs_for_android(configs)
-- https://developer.android.google.cn/ndk/guides/cmake
@@ -70,8 +78,8 @@ function _get_configs_for_android(configs)
end
end
--- get configs for iphoneos
-function _get_configs_for_iphoneos(configs)
+-- get configs for appleos
+function _get_configs_for_appleos(configs)
local envs = {}
local cflags = table.join(table.wrap(_get_buildenv("cxflags")), _get_buildenv("cflags"))
local cxxflags = table.join(table.wrap(_get_buildenv("cxflags")), _get_buildenv("cxxflags"))
@@ -81,10 +89,16 @@ function _get_configs_for_iphoneos(configs)
envs.CMAKE_STATIC_LINKER_FLAGS = table.concat(table.wrap(_get_buildenv("arflags")), ' ')
envs.CMAKE_EXE_LINKER_FLAGS = table.concat(table.wrap(_get_buildenv("ldflags")), ' ')
envs.CMAKE_SHARED_LINKER_FLAGS = table.concat(table.wrap(_get_buildenv("shflags")), ' ')
- envs.CMAKE_SYSTEM_NAME = "iOS"
+ if is_plat("watchos") then
+ envs.CMAKE_SYSTEM_NAME = "watchOS"
+ else
+ envs.CMAKE_SYSTEM_NAME = "iOS"
+ end
envs.CMAKE_FIND_ROOT_PATH_MODE_LIBRARY = "ONLY"
envs.CMAKE_FIND_ROOT_PATH_MODE_INCLUDE = "ONLY"
envs.CMAKE_FIND_ROOT_PATH_MODE_PROGRAM = "NEVER"
+ -- avoid install bundle targets
+ envs.CMAKE_MACOSX_BUNDLE = "NO"
for k, v in pairs(envs) do
table.insert(configs, "-D" .. k .. "=" .. v)
end
@@ -163,13 +177,12 @@ function _get_configs(artifacts_dir)
-- add prefix
local configs = {"-DCMAKE_INSTALL_PREFIX=" .. artifacts_dir, "-DCMAKE_INSTALL_LIBDIR=" .. path.join(artifacts_dir, "lib")}
- if is_plat("windows") and is_arch("x64") then
- table.insert(configs, "-A")
- table.insert(configs, "x64")
+ if is_plat("windows") then
+ _get_configs_for_windows(configs)
elseif is_plat("android") then
_get_configs_for_android(configs)
- elseif is_plat("iphoneos") then
- _get_configs_for_iphoneos(configs)
+ elseif is_plat("iphoneos", "watchos") then
+ _get_configs_for_appleos(configs)
elseif is_plat("mingw") then
_get_configs_for_mingw(configs)
elseif not is_plat(os.subhost()) then