From 71fc70b4d6d4ef6b8264f8a33f5cd261b643816c Mon Sep 17 00:00:00 2001 From: Rong Zhou Date: Thu, 22 Aug 2024 06:30:26 +0000 Subject: [PATCH] add FetchContent installation method description to README --- docs/README.md | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/docs/README.md b/docs/README.md index acd00ac0..b3fe2f4e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -68,6 +68,24 @@ C-SDK 使用 [cURL](http://curl.haxx.se/) 进行网络相关操作。无论是 如果在项目构建过程中出现环境相关的编译错误和链接错误,请确认这些选项是否都已经正确配置,以及所依赖的库是否都已经正确的安装。 +#### 通过 CMake 编译 + +如果想在 CMake 项目里使用 C-SDK,可以直接在 CMake 里导入 C-SDK: + +```cmake +INCLUDE(FetchContent) +FetchContent_Declare( + qiniu + GIT_REPOSITORY https://github.com/qiniu/c-sdk.git + GIT_TAG v7.8.0 +) +FetchContent_MakeAvailable(qiniu) +FIND_PACKAGE(CURL REQUIRED) +FIND_PACKAGE(OpenSSL REQUIRED) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE qiniu m) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE ${CURL_LIBRARIES}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE ${OPENSSL_LIBRARIES}) +``` @@ -169,7 +187,7 @@ typedef struct _Qiniu_Error { typedef struct _Qiniu_RS_StatRet { const char* hash; const char* mimeType; - Qiniu_Int64 fsize; + Qiniu_Int64 fsize; Qiniu_Int64 putTime; } Qiniu_RS_StatRet; ``` @@ -427,7 +445,7 @@ void stat(Qiniu_Client* client, const char* bucket, const char* key) typedef struct _Qiniu_RS_StatRet { const char* hash; const char* mimeType; - Qiniu_Int64 fsize; + Qiniu_Int64 fsize; Qiniu_Int64 putTime; } Qiniu_RS_StatRet; ``` @@ -456,8 +474,8 @@ void delete(Qiniu_Client* client, const char* bucket, const char* key) 复制和移动操作,需要指定源路径和目标路径。 ```{c} -void copy(Qiniu_Client* client, - const char* bucketSrc, const char* keySrc, +void copy(Qiniu_Client* client, + const char* bucketSrc, const char* keySrc, const char* bucketDest, const char* keyDest) { Qiniu_Error err = Qiniu_RS_Copy(client, bucketSrc, keySrc, bucketDest, keyDest); @@ -470,8 +488,8 @@ void copy(Qiniu_Client* client, ``` ```{c} -void move(Qiniu_Client* client, - const char* bucketSrc, const char* keySrc, +void move(Qiniu_Client* client, + const char* bucketSrc, const char* keySrc, const char* bucketDest, const char* keyDest) { Qiniu_Error err = Qiniu_RS_Move(client, bucketSrc, keySrc, bucketDest, keyDest); @@ -494,7 +512,7 @@ void move(Qiniu_Client* client, 调用`Qiniu_RS_BatchStat`可以批量查看多个文件的属性信息。 ```{c} -void batchStat(Qiniu_Client* client, +void batchStat(Qiniu_Client* client, Qiniu_RS_EntryPath* entries, Qiniu_ItemCount entryCount) { Qiniu_RS_BatchStatRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchStatRet)); @@ -551,7 +569,7 @@ typedef struct _Qiniu_RS_BatchStatRet { typedef struct _Qiniu_RS_StatRet { const char* hash; const char* mimeType; - Qiniu_Int64 fsize; + Qiniu_Int64 fsize; Qiniu_Int64 putTime; } Qiniu_RS_StatRet; ``` @@ -563,7 +581,7 @@ typedef struct _Qiniu_RS_StatRet { 调用`Qiniu_RS_BatchDelete`可以批量删除多个文件。 ```{c} -void batchDelete(Qiniu_Client* client, +void batchDelete(Qiniu_Client* client, Qiniu_RS_EntryPath* entries, Qiniu_ItemCount entryCount) { Qiniu_RS_BatchItemRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchItemRet)); @@ -604,7 +622,7 @@ typedef struct _Qiniu_RS_BatchItemRet { 调用`Qiniu_RS_BatchCopy`可以批量复制多个文件。 ```{c} -void batchCopy(Qiniu_Client* client, +void batchCopy(Qiniu_Client* client, Qiniu_RS_EntryPathPair* entryPairs, Qiniu_ItemCount entryCount) { Qiniu_RS_BatchItemRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchItemRet)); @@ -644,7 +662,7 @@ typedef struct _Qiniu_RS_EntryPathPair { 批量移动和批量复制很类似,唯一的区别就是调用`Qiniu_RS_BatchMove`。 ```{c} -void batchMove(Qiniu_Client* client, +void batchMove(Qiniu_Client* client, Qiniu_RS_EntryPathPair* entryPairs, Qiniu_ItemCount entryCount) { Qiniu_RS_BatchItemRet* rets = calloc(entryCount, sizeof(Qiniu_RS_BatchItemRet));