diff --git a/openVulkanoCpp/Host/WebResourceLoader.cpp b/openVulkanoCpp/Host/WebResourceLoader.cpp index 08e63bc..2fc1735 100644 --- a/openVulkanoCpp/Host/WebResourceLoader.cpp +++ b/openVulkanoCpp/Host/WebResourceLoader.cpp @@ -12,10 +12,16 @@ #include #include -#include +#if __has_include("curl/curl.h") + #include +#else + #pragma message ("Missing curl.h even though HAS_CURL is set") + #undef HAS_CURL +#endif namespace OpenVulkano { +#ifdef HAS_CURL namespace { size_t CurlDownloader(void* contents, size_t size, size_t memBlockCount, void* userData) @@ -26,6 +32,7 @@ namespace OpenVulkano return totalSize; } } +#endif bool WebResourceLoader::IsUrl(const std::string& str) { @@ -36,12 +43,16 @@ namespace OpenVulkano { m_cacheDirectory = AppFolders::GetAppCacheDir() / "resources"; std::filesystem::create_directories(m_cacheDirectory); +#ifdef HAS_CURL curl_global_init(CURL_GLOBAL_DEFAULT); +#endif } WebResourceLoader::~WebResourceLoader() { +#ifdef HAS_CURL curl_global_cleanup(); +#endif } std::filesystem::path WebResourceLoader::GetCacheFilePath(const std::string& url) @@ -55,6 +66,7 @@ namespace OpenVulkano Array WebResourceLoader::DownloadResource(const std::string& url) { std::vector buffer; +#ifdef HAS_CURL CURL* curl = curl_easy_init(); if (curl) { @@ -80,6 +92,7 @@ namespace OpenVulkano std::filesystem::path cacheFilePath = GetCacheFilePath(url); std::ofstream file(cacheFilePath, std::ios::binary); file.write(buffer.data(), buffer.size()); +#endif return Array(buffer); }