【Windows】Windows平台基于加速地址安装vcpkg并集成到Visual Studio 2017
基础运行环境
启动: 适用于 VS 2017 的 x64 本机工具命令提示
ninja
下载压缩包
https://gh-proxy.com/https:/github.com/ninja-build/ninja/releases/download/v1.13.1/ninja-win.zip
直接解压到c:/Windows (无需配置环境变量)
CMake
下载安装包
https://gh-proxy.com/https://github.com/Kitware/CMake/releases/download/v4.0.3/cmake-4.0.3-windows-x86_64.msi
手动安装
下载vcpkg
c:
cd /
git clone --depth=1 https://gh-proxy.com/github.com/microsoft/vcpkg
使用vscode
替换
https://github.com
为
https://gh-proxy.com/github.com
修改 C:\vcpkg\scripts\bootstrap.ps1
替换
if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_IDENTIFIER -match "ARMv[8,9] \(64-bit\)") {& "$scriptsDir/tls12-download-arm64.exe" github.com "/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg-arm64.exe" "$vcpkgRootDir\vcpkg.exe"
} else {& "$scriptsDir/tls12-download.exe" github.com "/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg.exe" "$vcpkgRootDir\vcpkg.exe"
}Write-Host ""if ($LASTEXITCODE -ne 0)
{Write-Error "Downloading vcpkg.exe failed. Please check your internet connection, or consider downloading a recent vcpkg.exe from https://gh-proxy.com/github.com/microsoft/vcpkg-tool with a browser."throw
}
为
if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64' -or $env:PROCESSOR_IDENTIFIER -match "ARMv[8,9] \(64-bit\)") {wget https://gh-proxy.com/github.com/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg-arm64.exe $vcpkgRootDir\vcpkg.exe
} else {wget https://gh-proxy.com/github.com/microsoft/vcpkg-tool/releases/download/$versionDate/vcpkg.exe -o $vcpkgRootDir\vcpkg.exe
}Write-Host ""if (-not $?)
{Write-Error "Downloading vcpkg.exe failed. Please check your internet connection, or consider downloading a recent vcpkg.exe from https://gh-proxy.com/github.com/microsoft/vcpkg-tool with a browser."throw
}
第三方库下载地址替换
修改C:\vcpkg\scripts\cmake\vcpkg_download_distfile.cmake:117行
将
vcpkg_list(SET params "x-download" "${arg_FILENAME}")foreach(url IN LISTS arg_URLS)vcpkg_list(APPEND params "--url=${url}")endforeach()
改为
foreach(url IN LISTS arg_URLS)# 将第三方库的地址更换为国内镜像源地址,这五个只是我目前找到的,如果有更多的需要替换的地址,形如:# string(REPLACE <oldUrl> <newUrl> url "${url}"),按照这个格式继续添加即可string(REPLACE "http://download.savannah.nongnu.org/releases/gta/" "https://marlam.de/gta/releases/" url "${url}")string(REPLACE "https://github.com/" "https://gh-proxy.com/github.com/" url "${url}")string(REPLACE "https://ftp.gnu.org/" "https://mirrors.aliyun.com/" url "${url}")string(REPLACE "https://raw.githubusercontent.com/" "https://ghfast.top/https://raw.githubusercontent.com/" url "${url}")string(REPLACE "http://ftp.gnu.org/pub/gnu/" "https://mirrors.aliyun.com/gnu/" url "${url}")string(REPLACE "https://ftp.postgresql.org/pub/" "https://mirrors.tuna.tsinghua.edu.cn/postgresql/" url "${url}")string(REPLACE "https://support.hdfgroup.org/ftp/lib-external/szip/2.1.1/src/" "https://distfiles.macports.org/szip/" url "${url}")vcpkg_list(APPEND params "--url=${url}")endforeach()
执行bootstrap-vcpkg.bat
注意在“适用于 VS 2017 的 x64 本机工具命令提示”中执行
C:\vcpkg>bootstrap-vcpkg.batvcpkg package management program version 2025-07-21-d4b65a2b83ae6c3526acd1c6f3b51aff2a884533See LICENSE.txt for license information.
Telemetry
---------
vcpkg collects usage data in order to help us improve your experience.
The data collected by Microsoft is anonymous.
You can opt-out of telemetry by re-running the bootstrap-vcpkg script with -disableMetrics,
passing --disable-metrics to vcpkg on the command line,
or by setting the VCPKG_DISABLE_METRICS environment variable.Read more about vcpkg telemetry at docs/about/privacy.md
使用vcpkg
全局安装程序库(openssl)
C:\vcpkg>vcpkg install openssl
Computing installation plan...
The following packages will be built and installed:openssl:x64-windows@3.5.2* vcpkg-cmake-get-vars:x64-windows@2025-05-29
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-windows...
Compiler found: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
Restored 0 package(s) from C:\Users\yeqiang\AppData\Local\vcpkg\archives in 146 us. Use --debug to see more details.
Installing 1/2 vcpkg-cmake-get-vars:x64-windows@2025-05-29...
Building vcpkg-cmake-get-vars:x64-windows@2025-05-29...
-- Installing: C:/vcpkg/packages/vcpkg-cmake-get-vars_x64-windows/share/vcpkg-cmake-get-vars/vcpkg_cmake_get_vars.cmake
-- Installing: C:/vcpkg/packages/vcpkg-cmake-get-vars_x64-windows/share/vcpkg-cmake-get-vars/cmake_get_vars
-- Installing: C:/vcpkg/packages/vcpkg-cmake-get-vars_x64-windows/share/vcpkg-cmake-get-vars/cmake_get_vars/CMakeLists.txt
-- Installing: C:/vcpkg/packages/vcpkg-cmake-get-vars_x64-windows/share/vcpkg-cmake-get-vars/cmake-get-vars.cmake.in
-- Installing: C:/vcpkg/packages/vcpkg-cmake-get-vars_x64-windows/share/vcpkg-cmake-get-vars/vcpkg-port-config.cmake
-- Installing: C:/vcpkg/packages/vcpkg-cmake-get-vars_x64-windows/share/vcpkg-cmake-get-vars/copyright
-- Performing post-build validation
Starting submission of vcpkg-cmake-get-vars:x64-windows@2025-05-29 to 1 binary cache(s) in the background
Elapsed time to handle vcpkg-cmake-get-vars:x64-windows: 51.9 ms
vcpkg-cmake-get-vars:x64-windows package ABI: 6ed36a3d2a83ae143b6f8887aed846b6944a5cdeff44fcf9d4f30eb4a7c86389
Installing 2/2 openssl:x64-windows@3.5.2...
Building openssl:x64-windows@3.5.2...
Downloading https://gh-proxy.com/github.com/openssl/openssl/archive/openssl-3.5.2.tar.gz -> openssl-openssl-openssl-3.5.2.tar.gz
Successfully downloaded openssl-openssl-openssl-3.5.2.tar.gz
-- Extracting source C:/vcpkg/downloads/openssl-openssl-openssl-3.5.2.tar.gz
-- Applying patch cmake-config.patch
-- Applying patch command-line-length.patch
-- Applying patch script-prefix.patch
-- Applying patch windows/install-layout.patch
-- Applying patch windows/install-pdbs.patch
-- Applying patch unix/android-cc.patch
-- Applying patch unix/move-openssldir.patch
-- Applying patch unix/no-empty-dirs.patch
-- Applying patch unix/no-static-libs-for-shared.patch
-- Using source at C:/vcpkg/buildtrees/openssl/src/nssl-3.5.2-e03035cfd7.clean
-- Found external ninja('1.13.1').
-- Getting CMake variables for x64-windows
-- Loading CMake variables from C:/vcpkg/buildtrees/openssl/cmake-get-vars_C_CXX-x64-windows.cmake.log
Downloading https://gh-proxy.com/github.com/StrawberryPerl/Perl-Dist-Strawberry/releases/download/SP_54201_64bit/strawberry-perl-5.42.0.1-64bit-portable.zip -> strawberry-perl-5.42.0.1-64bit-portable.zip
Successfully downloaded strawberry-perl-5.42.0.1-64bit-portable.zip
Downloading nasm-2.16.03-win64.zip, trying https://www.nasm.us/pub/nasm/releasebuilds/2.16.03/win64/nasm-2.16.03-win64.zip
Successfully downloaded nasm-2.16.03-win64.zip
-- Getting CMake variables for x64-windows
Downloading jom_1_1_4.zip, trying https://download.qt.io/official_releases/jom/jom_1_1_4.zip
Successfully downloaded jom_1_1_4.zip
-- Prerunning x64-windows-dbg
-- Building x64-windows-dbg
-- Prerunning x64-windows-rel
-- Building x64-windows-rel
-- Fixing pkgconfig file: C:/vcpkg/packages/openssl_x64-windows/lib/pkgconfig/libcrypto.pc
-- Fixing pkgconfig file: C:/vcpkg/packages/openssl_x64-windows/lib/pkgconfig/libssl.pc
-- Fixing pkgconfig file: C:/vcpkg/packages/openssl_x64-windows/lib/pkgconfig/openssl.pc
Downloading msys2-mingw-w64-x86_64-pkgconf-1~2.4.3-1-any.pkg.tar.zst, trying https://mirror.msys2.org/mingw/mingw64/mingw-w64-x86_64-pkgconf-1~2.4.3-1-any.pkg.tar.zst
Successfully downloaded msys2-mingw-w64-x86_64-pkgconf-1~2.4.3-1-any.pkg.tar.zst
Downloading msys2-msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst, trying https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst
warning: Download https://mirror.msys2.org/msys/x86_64/msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst failed -- retrying after 1000ms
Successfully downloaded msys2-msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst
-- Using msys root at C:/vcpkg/downloads/tools/msys2/9272adbcaf19caef
-- Fixing pkgconfig file: C:/vcpkg/packages/openssl_x64-windows/debug/lib/pkgconfig/libcrypto.pc
-- Fixing pkgconfig file: C:/vcpkg/packages/openssl_x64-windows/debug/lib/pkgconfig/libssl.pc
-- Fixing pkgconfig file: C:/vcpkg/packages/openssl_x64-windows/debug/lib/pkgconfig/openssl.pc
-- Installing: C:/vcpkg/packages/openssl_x64-windows/share/openssl/usage
-- Installing: C:/vcpkg/packages/openssl_x64-windows/share/openssl/copyright
-- Performing post-build validation
Starting submission of openssl:x64-windows@3.5.2 to 1 binary cache(s) in the background
Elapsed time to handle openssl:x64-windows: 14 min
openssl:x64-windows package ABI: 1dd5b794138c062139cdba6b87e8c4344382e24dd173b65f5e46cea0d6a4f100
Total install time: 14 min
Installed contents are licensed to you by owners. Microsoft is not responsible for, nor does it grant any licenses to, third-party packages.
Packages installed in this vcpkg installation declare the following licenses:
Apache-2.0
MIT
openssl is compatible with built-in CMake targets:find_package(OpenSSL REQUIRED)target_link_libraries(main PRIVATE OpenSSL::SSL)target_link_libraries(main PRIVATE OpenSSL::Crypto)Completed submission of vcpkg-cmake-get-vars:x64-windows@2025-05-29 to 1 binary cache(s) in 23.8 ms
Waiting for 1 remaining binary cache submissions...
Completed submission of openssl:x64-windows@3.5.2 to 1 binary cache(s) in 1.8 s (1/1)
All requested installations completed successfully in: 14 min
相当耗时!对比linux平台yum、apt等直接安装方式要慢一大截,比go这种编译型的也慢一大截,体验不好!
安装产生的主要内容
下载缓存
C:\vcpkg>dir downloads驱动器 C 中的卷没有标签。卷的序列号是 BE84-90DBC:\vcpkg\downloads 的目录2025/08/20 14:44 <DIR> .
2025/08/20 14:09 <DIR> ..
2025/08/20 14:09 1,312,005 7z2409.7z
2025/08/20 14:09 1,348,869 7z2409.7z.exe
2025/08/20 14:09 2,267,282 abseil-abseil-cpp-20250127.1.tar.gz
2025/08/20 14:39 1,696,930 jom_1_1_4.zip
2025/08/20 14:42 90,772 msys2-mingw-w64-x86_64-pkgconf-1~2.4.3-1-any.pkg.tar.zst
2025/08/20 14:44 1,932,245 msys2-msys2-runtime-3.6.2-2-x86_64.pkg.tar.zst
2025/08/20 14:38 513,543 nasm-2.16.03-win64.zip
2025/08/20 14:31 53,361,814 openssl-openssl-openssl-3.5.2.tar.gz
2025/08/20 14:09 107,886,044 PowerShell-7.2.24-win-x64.zip
2025/08/20 14:37 302,439,100 strawberry-perl-5.42.0.1-64bit-portable.zip
2025/08/20 14:44 <DIR> tools
构建目录(源代码释放目录)
C:\vcpkg>dir buildtrees驱动器 C 中的卷没有标签。卷的序列号是 BE84-90DBC:\vcpkg\buildtrees 的目录2025/08/20 14:31 <DIR> .
2025/08/20 14:09 <DIR> ..
2025/08/20 14:09 <DIR> abseil
2025/08/20 14:09 <DIR> c-ares
2025/08/20 14:31 <DIR> detect_compiler
2025/08/20 14:09 <DIR> grpc
2025/08/20 14:41 <DIR> openssl
2025/08/20 14:09 <DIR> protobuf
2025/08/20 14:09 <DIR> re2
2025/08/20 14:09 <DIR> utf8-range
2025/08/20 14:09 <DIR> vcpkg-cmake
2025/08/20 14:09 <DIR> vcpkg-cmake-config
2025/08/20 14:31 <DIR> vcpkg-cmake-get-vars
2025/08/20 14:09 <DIR> zlib
库目录(编译成品)
C:\vcpkg>dir packages驱动器 C 中的卷没有标签。卷的序列号是 BE84-90DBC:\vcpkg\packages 的目录2025/08/20 14:44 <DIR> .
2025/08/20 14:09 <DIR> ..
2025/08/20 14:09 <DIR> abseil_x64-windows
2025/08/20 14:31 <DIR> detect_compiler_x64-windows
2025/08/20 14:44 <DIR> openssl_x64-windows
2025/08/20 14:09 <DIR> vcpkg-cmake-config_x64-windows
2025/08/20 14:31 <DIR> vcpkg-cmake-get-vars_x64-windows
2025/08/20 14:09 <DIR> vcpkg-cmake_x64-windows0 个文件 0 字节8 个目录 338,437,447,680 可用字节C:\vcpkg>tree packages\openssl_x64-windows
文件夹 PATH 列表
卷序列号为 000001C4 BE84:90DB
C:\VCPKG\PACKAGES\OPENSSL_X64-WINDOWS
├─bin
├─debug
│ ├─bin
│ └─lib
│ └─pkgconfig
├─include
│ └─openssl
├─lib
│ └─pkgconfig
└─share└─openssl
安装好的库
C:\vcpkg>tree installed
文件夹 PATH 列表
卷序列号为 000001EA BE84:90DB
C:\VCPKG\INSTALLED
├─vcpkg
│ ├─info
│ └─updates
└─x64-windows├─bin├─debug│ ├─bin│ └─lib│ └─pkgconfig├─include│ └─openssl├─lib│ └─pkgconfig└─share├─openssl├─vcpkg-cmake├─vcpkg-cmake-config└─vcpkg-cmake-get-vars└─cmake_get_varsC:\vcpkg>dir installed\x64-windows\bin驱动器 C 中的卷没有标签。卷的序列号是 BE84-90DBC:\vcpkg\installed\x64-windows\bin 的目录2025/08/20 14:44 <DIR> .
2025/08/20 14:44 <DIR> ..
2025/08/20 14:42 102,912 legacy.dll
2025/08/20 14:42 888,832 legacy.pdb
2025/08/20 14:42 5,186,048 libcrypto-3-x64.dll
2025/08/20 14:42 19,402,752 libcrypto-3-x64.pdb
2025/08/20 14:42 853,504 libssl-3-x64.dll
2025/08/20 14:42 4,149,248 libssl-3-x64.pdb6 个文件 30,583,296 字节2 个目录 338,430,484,480 可用字节
VS2017集成vcpkg
全局集成方式(非常方便,体验好)
管理员权限启动命令行,执行 vcpkg integrate install
**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.45
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'C:\Windows\System32>cd /C:\>cd vcpkgC:\vcpkg>vcpkg integrate install
Applied user-wide integration for this vcpkg root.
CMake projects should use: "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"All MSBuild C++ projects can now #include any installed libraries. Linking will be handled automatically. Installing new libraries will make them instantly available.
工作原理:
这个命令做了什么?它没有修改你的任何一个项目文件,而是在系统级为Visual Studio注册了你的 vcpkg
目录。具体来说,它在 %USERPROFILE%\AppData\Local\Microsoft\MSBuild\v4.0
目录下添加了一个 .props
文件,这个文件会被所有Visual Studio C++项目自动导入。
效果:
从此以后,在任何VS2017的C++项目中,您只需要:
#include <openssl/ssl.h>
- 在“项目属性” -> “链接器” -> “输入” -> “附加依赖项”中,简单地添加库名,例如
libssl.lib
和libcrypto.lib
。
所有头文件路径和库文件路径都会由vcpkg自动提供给项目,无需手动指定。 安装新的库后,也无需任何额外配置,即可立即在项目中使用。
验证 OpenSSL 3.5.2 在 Visual Studio 2017 中的配置
下面提供一个完整的示例,包括项目配置步骤和验证代码,用于测试 OpenSSL 3.5.2 是否正常安装并可用。
项目配置步骤
-
确保已完成 vcpkg 全局集成(如前所述):
cmd
cd c:\vcpkg vcpkg integrate install
-
在 Visual Studio 2017 中创建一个新的 C++ 控制台项目
-
配置项目属性:
-
打开项目属性页(右键项目 → 属性)
-
确保"平台"设置为 x64(与您安装的 OpenSSL 架构匹配)
-
在"配置属性" → “C/C++” → "代码生成"中,将"运行库"设置为 /MT 或 /MTd(与 OpenSSL 的编译选项匹配)
-
在"配置属性" → “链接器” → “输入” → "附加依赖项"中添加:
text
libssl.lib libcrypto.lib
-
验证代码 (main.cpp)
cpp
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/ssl.h>
#include <openssl/conf.h>
#include <iostream>
#include <vector>
#include <iomanip>
#include <sstream>// 打印OpenSSL版本信息
void print_openssl_version() {std::cout << "OpenSSL版本信息:" << std::endl;std::cout << " 版本: " << OPENSSL_VERSION_TEXT << std::endl;std::cout << " 构建时间: " << OPENSSL_BUILT_ON << std::endl;std::cout << " 平台: " << OPENSSL_PLATFORM << std::endl;std::cout << " 选项: " << OPENSSL_CFLAGS << std::endl;
}// 计算字符串的MD5哈希值
std::string calculate_md5(const std::string& input) {EVP_MD_CTX* context = EVP_MD_CTX_new();if (!context) {throw std::runtime_error("无法创建MD5上下文");}if (EVP_DigestInit_ex(context, EVP_md5(), nullptr) != 1) {EVP_MD_CTX_free(context);throw std::runtime_error("无法初始化MD5摘要");}if (EVP_DigestUpdate(context, input.c_str(), input.length()) != 1) {EVP_MD_CTX_free(context);throw std::runtime_error("无法更新MD5摘要");}unsigned char hash[EVP_MAX_MD_SIZE];unsigned int lengthOfHash = 0;if (EVP_DigestFinal_ex(context, hash, &lengthOfHash) != 1) {EVP_MD_CTX_free(context);throw std::runtime_error("无法完成MD5摘要");}EVP_MD_CTX_free(context);// 将哈希值转换为十六进制字符串std::stringstream ss;for (unsigned int i = 0; i < lengthOfHash; ++i) {ss << std::hex << std::setw(2) << std::setfill('0') << static_cast<int>(hash[i]);}return ss.str();
}// 初始化OpenSSL
void init_openssl() {SSL_library_init();SSL_load_error_strings();OpenSSL_add_all_algorithms();
}// 清理OpenSSL资源
void cleanup_openssl() {EVP_cleanup();CRYPTO_cleanup_all_ex_data();
}int main() {std::cout << "开始验证OpenSSL安装..." << std::endl << std::endl;try {// 初始化OpenSSLinit_openssl();// 打印版本信息print_openssl_version();std::cout << std::endl << "测试MD5哈希计算..." << std::endl;// 测试字符串std::string test_string = "Hello, OpenSSL 3.5.2!";std::cout << "原始字符串: " << test_string << std::endl;// 计算MD5std::string md5_hash = calculate_md5(test_string);std::cout << "MD5哈希值: " << md5_hash << std::endl;// 验证已知的MD5值std::string expected_md5 = calculate_md5("Hello, OpenSSL 3.5.2!");std::cout << "预期哈希值: " << expected_md5 << std::endl;if (md5_hash == expected_md5) {std::cout << "√ MD5哈希验证成功!" << std::endl;} else {std::cout << "× MD5哈希验证失败!" << std::endl;}// 清理OpenSSLcleanup_openssl();std::cout << std::endl << "OpenSSL验证完成!" << std::endl;}catch (const std::exception& e) {std::cerr << "错误: " << e.what() << std::endl;// 打印OpenSSL错误队列char err_buf[512];ERR_error_string_n(ERR_get_error(), err_buf, sizeof(err_buf));std::cerr << "OpenSSL错误: " << err_buf << std::endl;return 1;}std::cout << std::endl << "按回车键退出...";std::cin.get();return 0;
}
输出
程序输出以下内容:
开始验证OpenSSL安装...OpenSSL版本信息:版本: OpenSSL 3.5.2 5 Aug 2025构建时间: 2平台: 3选项: 1测试MD5哈希计算...
原始字符串: Hello, OpenSSL 3.5.2!
MD5哈希值: acd08868dd770d975a2fd21f3753fe22
预期哈希值: acd08868dd770d975a2fd21f3753fe22
√ MD5哈希验证成功!OpenSSL验证完成!按回车键退出...
将 VC 工程转换为 CMake 工程并支持 Ninja 构建(vcpkg的构建方案)
创建 CMakeLists.txt 文件
在项目根目录创建 CMakeLists.txt
,内容如下:
cmake
cmake_minimum_required(VERSION 3.10)# 项目名称和版本
project(openssl-sampleVERSION 1.0.0DESCRIPTION "OpenSSL Sample Project"LANGUAGES CXX
)# 设置C++标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)# 设置vcpkg工具链(根据您的vcpkg安装路径调整)
set(CMAKE_TOOLCHAIN_FILE "C:/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "Vcpkg toolchain file")# 查找OpenSSL包
find_package(OpenSSL REQUIRED)# 打印找到的OpenSSL信息
message(STATUS "Found OpenSSL: ${OPENSSL_VERSION}")
message(STATUS "OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
message(STATUS "OpenSSL libraries: ${OPENSSL_LIBRARIES}")# 添加可执行文件
add_executable(${PROJECT_NAME}src/main.cpp
)# 设置目标属性
target_include_directories(${PROJECT_NAME} PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE ${OPENSSL_LIBRARIES})# 设置输出目录(可选)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)# 安装规则(可选)
install(TARGETS ${PROJECT_NAME}RUNTIME DESTINATION binLIBRARY DESTINATION libARCHIVE DESTINATION lib
)
不顺利,放弃!