Skip to content
This repository was archived by the owner on Jan 7, 2020. It is now read-only.

Commit 95c94d9

Browse files
committed
Update build scripts
1 parent 8ab9c1a commit 95c94d9

File tree

11 files changed

+16
-33
lines changed

11 files changed

+16
-33
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ environment:
1818
install:
1919
- git submodule init
2020
- git submodule update
21-
- powershell .\scripts\prepare.ps1 %VCPKG_ROOT%
21+
- powershell .\scripts\prepare.ps1
2222

2323
build_script:
2424
- powershell .\scripts\generate.ps1 %CONFIGURATION%

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ add_definitions(-DBOOST_CONFIG_SUPPRESS_OUTDATED_MESSAGE
1919
-DWIN32_LEAN_AND_MEAN
2020
-DNOMINMAX)
2121

22-
find_package(Iconv REQUIRED)
22+
find_package(unofficial-iconv CONFIG REQUIRED)
2323

2424
include(FixLinkConflict)
2525

2626
file(GLOB_RECURSE SOURCE_FILES src/*.cpp)
2727
set(LIB_NAME "com.example.demo")
2828
add_library(${LIB_NAME} SHARED ${SOURCE_FILES})
2929

30-
target_link_libraries(${LIB_NAME} ${ICONV_AND_DEPS_LIBRARIES})
30+
target_link_libraries(${LIB_NAME} PRIVATE unofficial::iconv::libiconv unofficial::iconv::libcharset)
3131

3232
cotire(${LIB_NAME})
3333

README.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,11 @@ CQ_MAIN {
7575

7676
本项目使用 [CMake](https://cmake.org/) 构建,依赖项通过 [vcpkg](https://github.com/Microsoft/vcpkg) 管理。如果你没有使用过这两个工具,请先前往它们的官方网站了解基本用法。
7777

78-
在开始使用之前,请确保你已经安装了 Git 和 CMake,且 `PATH` 中存在 `git``cmake` 命令。不需要安装 vcpkg,后面的脚本中会自动安装。
78+
在开始使用之前,请确保你已经安装了 Git,且 `PATH` 中存在 `git` 命令。不需要安装 vcpkg,后面的脚本中会自动安装。
7979

80-
除了 Git、CMake,还需要安装 VC++ 2017 v141 工具集,**并且安装 VS 的英文语言包(vcpkg 要求)**
80+
然后确保安装了 Visual Studio **2017**(暂不支持 2019),并勾选「使用 C++ 的桌面开发」,确保安装了 CMake、**VC++ 2017 v141**、Windows 10 SDK 这三个组件。其中,如果系统中已经安装了 CMake,无需再在 VS Installer 中安装,但需要确保命令已添加进 `PATH`
81+
82+
除此之外,vcpkg 还要求安装 VS 2017 的英文语言包。
8183

8284
### 下载 SDK
8385

@@ -96,7 +98,7 @@ powershell .\scripts\prepare.ps1
9698

9799
[`scripts/prepare.ps1`](scripts/prepare.ps1) 脚本会在当前项目目录的 `vcpkg` 子目录中安装 vcpkg,并安装所需依赖。
98100

99-
注意,如果 PowerShell 提示不让运行脚本,需要先使用管理员权限打开 PowerShell,运行 `Set-ExecutionPolicy Unrestricted`,然后再重新运行上面的脚本;如果 vcpkg 安装依赖时出错,比较常见的问题是网络超时,请适当设置 `HTTP_PROXY``HTTPS_PROXY`
101+
*注意,如果 PowerShell 提示不让运行脚本,需要先使用管理员权限打开 PowerShell,运行 `Set-ExecutionPolicy Unrestricted`,然后再重新运行上面的脚本;如果 vcpkg 安装依赖时出错,比较常见的问题是网络超时,请适当设置 `HTTP_PROXY``HTTPS_PROXY`*
100102

101103
### 修改 App Id 和相关信息
102104

@@ -119,7 +121,7 @@ powershell .\scripts\generate.ps1 Debug
119121
powershell .\scripts\build.ps1 Debug
120122
```
121123

122-
上面两条命令分别生成 build 目录和构建项目,将 `Debug` 改为 `Release` 可以构建 release 版本。如果安装了 CMake 还没支持的较新版本 VS,需要先手动进入 VS 2017 的 Developer Command Prompt,再执行上面的命令。
124+
上面两条命令分别生成 build 目录和构建项目,将 `Debug` 改为 `Release` 可以构建 release 版本。如果安装了 CMake 还没支持的较新版本 VS(例如 VS 2019),需要先手动进入 VS 2017 的 Developer Command Prompt,再执行上面的命令。
123125

124126
如果你使用 VS Code,可以直接运行 task;如果使用 VS,可以直接选择菜单 CMake - 全部生成。
125127

@@ -160,13 +162,13 @@ git submodule update
160162

161163
### 安装依赖
162164

163-
如果需要安装依赖,请使用 triplet `x86-windows-static-custom`,参考如下命令
165+
如果需要安装依赖,可以直接使用 vcpkg,通过 `--triplet x86-windows-static-custom` 指定 triplet,或者使用 SDK 提供的包装脚本(参数和 vcpkg 相同),例如
164166

165167
```ps1
166-
.\vcpkg\vcpkg.exe --triplet x86-windows-static-custom install curl
168+
.\scripts\vcpkg.ps1 install curl
167169
```
168170

169-
然后按需在 `CMakeLists.txt` 添加相应 `find_package` 语句和修改 `target_link_libraries`。注意,vcpkg 的 CMake 工具链文件有时并不能正确找到依赖的依赖的 LIB 文件,需要手动编写 `FindXxx.cmake` 文件,参考 [`cmake/Modules/FindIconv.cmake`](cmake/Modules/FindIconv.cmake)
171+
然后按需在 `CMakeLists.txt` 添加相应 `find_package` 语句和修改 `target_link_libraries`。注意,vcpkg 的 CMake 工具链文件有时并不能正确找到依赖的依赖的 LIB 文件,需要手动编写 `FindXxx.cmake` 文件,参考 [`richardchien/coolq-http-api/cmake/Modules/FindCURL.cmake`](https://github.com/richardchien/coolq-http-api/blob/master/cmake/Modules/FindCURL.cmake)
170172

171173
### 固定依赖包版本
172174

cmake/Modules/FindIconv.cmake

Lines changed: 0 additions & 23 deletions
This file was deleted.

cmake/x86-windows-static-custom.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ set(VCPKG_TARGET_ARCHITECTURE x86)
22
set(VCPKG_CRT_LINKAGE dynamic)
33
set(VCPKG_LIBRARY_LINKAGE static)
44
set(VCPKG_PLATFORM_TOOLSET v141)
5+
6+
if (PORT MATCHES "^libiconv$")
7+
set(VCPKG_LIBRARY_LINKAGE dynamic)
8+
endif()

scripts/build.ps1

-22 Bytes
Binary file not shown.

scripts/generate.ps1

-22 Bytes
Binary file not shown.

scripts/helpers.ps1

1.9 KB
Binary file not shown.

scripts/post_build.ps1

-32 Bytes
Binary file not shown.

scripts/prepare.ps1

-302 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)