Skip to content

Commit

Permalink
refactor:调整install输出路径
Browse files Browse the repository at this point in the history
  • Loading branch information
overwriter committed Oct 30, 2023
1 parent 106888f commit 8e546ca
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CApi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,8 @@ add_library(CApi SHARED
target_link_libraries(CApi PRIVATE Qt${QT_VERSION_MAJOR}::Core QCloudMusicApi)

target_compile_definitions(CApi PRIVATE CAPI_LIBRARY)

set(PUBLIC_HEADERS
capi.h
)
install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_HEADER_OUTPUT_DIRECTORY})
17 changes: 13 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,19 @@ project(QCloudMusicApiProject VERSION 1.0)
# C++标准
set(CMAKE_CXX_STANDARD 17)

# 设置动态库和可执行程序的输出路径为 bin 目录
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
# set default output path
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/lib)
set(CMAKE_HEADER_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/output/include)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY})

# 添加子目录
add_subdirectory(QCloudMusicApi)
Expand Down
4 changes: 3 additions & 1 deletion QCloudMusicApi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ target_link_libraries(QCloudMusicApi Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_

target_compile_definitions(QCloudMusicApi PRIVATE QCLOUDMUSICAPI_LIBRARY)

set(PUBLIC_HEADERS module.h)
set(PUBLIC_HEADERS
module.h
)
install(FILES ${PUBLIC_HEADERS} DESTINATION ${CMAKE_HEADER_OUTPUT_DIRECTORY})
install(DIRECTORY ${OPENSSL_INCLUDE_DIR}/../bin DESTINATION ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/../)
3 changes: 0 additions & 3 deletions QCloudMusicApi/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,6 @@ static auto createRequest(QNetworkAccessManager::Operation method, QString urlSt
{ "cookie", {} }
};

//设置默认超时时间
reply->manager()->setTransferTimeout(QNetworkRequest::DefaultTransferTimeoutConstant);

// 开启一个局部的事件循环,等待响应结束,退出
QEventLoop eventLoop;
QObject::connect(reply->manager(), &QNetworkAccessManager::finished, &eventLoop, &QEventLoop::quit); // 请求结束时退出事件循环
Expand Down
8 changes: 8 additions & 0 deletions QCloudMusicApi/util/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,13 @@ QList<QNetworkCookie> mapToCookie(QVariantMap &cookie) {
}
return list;
}
QVariantMap mergeMap(const QVariantMap &map0, const QVariantMap &map1)
{
QVariantMap result = map0; //复制第一个map
for (auto i = map1.constBegin(); i != map1.constEnd(); ++i) {
result.insert(i.key(), i.value()); //插入或覆盖第二个map的键值对
}
return result;
}
}
#endif // INDEX_H
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Qt版 网易云音乐 API
## 需求和依赖
本项目需要以下库和工具:

- Qt >= 5.10
- Qt >= 5.12
- OpenSSL >= 1.1.1
- conan2

Expand Down
2 changes: 1 addition & 1 deletion Test/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void MainWindow::updateCookie(QVariantMap ret) {
if (ret["body"].toMap()["token"].isValid()) {
map["MUSIC_A"] = ret["body"].toMap()["token"];
}
map.insert(newMap);
Index::mergeMap(map, newMap);
cookie = Index::mapToString(map);
}

Expand Down

0 comments on commit 8e546ca

Please sign in to comment.