From cb925d005c198ea9a4ab953f8c9a7478a1702567 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 10 Nov 2024 22:37:28 +0300 Subject: [PATCH] add libcurl --- .github/workflows/appimage.yml | 2 +- .github/workflows/macos.yml | 2 +- .github/workflows/windows.yml | 2 +- src/CMakeLists.txt | 4 +++- test/curltest.cpp | 18 ++++++++++++++++++ vcpkg.json | 3 ++- 6 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 test/curltest.cpp diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml index a0e6e6fa..1bf4ae09 100644 --- a/.github/workflows/appimage.yml +++ b/.github/workflows/appimage.yml @@ -2,7 +2,7 @@ name: C/C++ AppImage on: push: - branches: [ "main", "release-**"] + branches: [ "main", "release-**", "curl"] pull_request: branches: [ "main" ] diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index e4ddf55a..c8050bcb 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -2,7 +2,7 @@ name: Macos Build on: push: - branches: [ "main", "release-**"] + branches: [ "main", "release-**", "curl"] pull_request: branches: [ "main" ] diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index b14c32d0..c5c52290 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -2,7 +2,7 @@ name: Windows Build on: push: - branches: [ "main", "release-**"] + branches: [ "main", "release-**", "curl"] pull_request: branches: [ "main" ] diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ecd0c98b..7eecaef9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,6 +15,7 @@ find_package(GLEW REQUIRED) find_package(OpenAL REQUIRED) find_package(ZLIB REQUIRED) find_package(PNG REQUIRED) +find_package(CURL REQUIRED) if (NOT APPLE) find_package(EnTT REQUIRED) endif() @@ -61,5 +62,6 @@ if(UNIX) endif() include_directories(${LUA_INCLUDE_DIR}) +include_directories(${CURL_INCLUDE_DIR}) target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_link_libraries(${PROJECT_NAME} ${LIBS} glfw OpenGL::GL ${OPENAL_LIBRARY} GLEW::GLEW ZLIB::ZLIB PNG::PNG ${VORBISLIB} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) +target_link_libraries(${PROJECT_NAME} ${LIBS} glfw OpenGL::GL ${OPENAL_LIBRARY} GLEW::GLEW ZLIB::ZLIB PNG::PNG CURL::libcurl ${VORBISLIB} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS}) diff --git a/test/curltest.cpp b/test/curltest.cpp new file mode 100644 index 00000000..a8d3424e --- /dev/null +++ b/test/curltest.cpp @@ -0,0 +1,18 @@ +#include + +#include + +size_t write_callback(char *ptr, size_t size, size_t nmemb, void *userdata) { + return size * nmemb; +} + +TEST(curltest, curltest) { + if (CURL* curl = curl_easy_init()) { + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, "https://github.com"); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); + res = curl_easy_perform(curl); + std::cout << curl_easy_strerror(res) << std::endl; + curl_easy_cleanup(curl); + } +} diff --git a/vcpkg.json b/vcpkg.json index 54ee4ec8..17145c4a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -12,6 +12,7 @@ "luajit", "libvorbis", "entt", - "gtest" + "gtest", + "curl" ] }