Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ option(COUNTLY_USE_CUSTOM_HTTP "Use a custom HTTP library" OFF)
option(COUNTLY_USE_SQLITE "Use SQLite" OFF)
option(COUNTLY_BUILD_TESTS "Build test programs" OFF)

if (NOT BUILD_SHARED_LIBS AND NOT COUNTLY_CUSTOM_HTTP)
if (NOT WIN32 AND NOT BUILD_SHARED_LIBS AND NOT COUNTLY_CUSTOM_HTTP)
message(FATAL_ERROR "You must provide a custom HTTP function when compiling statically.")
endif()

Expand All @@ -33,6 +33,13 @@ target_link_libraries(countly Threads::Threads)

target_include_directories(countly PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/json/include)

if (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
find_package(OpenSSL REQUIRED)
target_include_directories(countly PRIVATE ${OPENSSL_INCLUDE_DIR})
target_link_libraries(countly ${OPENSSL_LIBRARIES})

if(COUNTLY_USE_CUSTOM_HTTP)
target_compile_definitions(countly PRIVATE COUNTLY_USE_CUSTOM_HTTP)
elseif(NOT WIN32)
Expand All @@ -47,12 +54,6 @@ if(COUNTLY_USE_SQLITE)
find_package(Sqlite3)
target_include_directories(countly PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/sqlite)
target_link_libraries(countly sqlite3)
if (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
find_package(OpenSSL REQUIRED)
target_include_directories(countly PRIVATE ${OPENSSL_INCLUDE_DIRS})
target_link_libraries(countly ${OPENSSL_LIBRARIES})
endif()

if(COUNTLY_BUILD_TESTS)
Expand Down
6 changes: 6 additions & 0 deletions include/countly.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
#include "nlohmann/json.hpp"
using json = nlohmann::json;

#ifdef _WIN32
#undef ERROR
#endif

#define COUNTLY_SDK_NAME "cpp-native-unknown"
#define COUNTLY_SDK_VERSION "0.1.0"
#define COUNTLY_API_VERSION "19.8.0"
Expand Down Expand Up @@ -136,6 +140,8 @@ class Countly {
void SetPath(const std::string& path) {
#ifdef COUNTLY_USE_SQLITE
setDatabasePath(path);
#elif defined _WIN32
UNREFERENCED_PARAMETER(path);
#endif
}

Expand Down
3 changes: 2 additions & 1 deletion src/countly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ using json = nlohmann::json;
#ifdef _WIN32
#include "Windows.h"
#include "WinHTTP.h"
#undef ERROR
#pragma comment(lib, "winhttp.lib")
#else
#include "curl/curl.h"
Expand Down Expand Up @@ -694,7 +695,7 @@ Countly::HTTPResponse Countly::sendHTTP(std::string path, std::string data) {
}

if (hRequest) {
bool ok = WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, use_post ? data.c_str() : WINHTTP_NO_REQUEST_DATA, use_post ? data.size() : 0, 0, nullptr) != 0;
bool ok = WinHttpSendRequest(hRequest, WINHTTP_NO_ADDITIONAL_HEADERS, 0, use_post ? (LPVOID)data.data() : WINHTTP_NO_REQUEST_DATA, use_post ? data.size() : 0, 0, 0) != 0;
if (ok) {
ok = WinHttpReceiveResponse(hRequest, NULL);
if (ok) {
Expand Down