Skip to content

Commit

Permalink
Cmake logs (#107)
Browse files Browse the repository at this point in the history
* logs

* climits

* flag logs

* moar logs
  • Loading branch information
turtledreams authored Feb 1, 2023
1 parent dc0eec4 commit 72c8deb
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
18 changes: 18 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ option(COUNTLY_USE_SQLITE "Use SQLite" OFF)
option(COUNTLY_BUILD_TESTS "Build test programs" OFF)
option(COUNTLY_BUILD_SAMPLE "Build Sample programs" OFF)

message("Build shared libraries:" ${BUILD_SHARED_LIBS})
message("Create a module definition (.def) on Windows.:" ${CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS})
message("Use a custom HTTP library:" ${COUNTLY_USE_CUSTOM_HTTP})
message("Use a custom SHA 256 library:" ${COUNTLY_USE_CUSTOM_SHA256})
message("Use SQLite:" ${COUNTLY_USE_SQLITE})
message("Build test programs:" ${COUNTLY_BUILD_TESTS})
message("Build Sample programs:" ${COUNTLY_BUILD_SAMPLE})

if (NOT WIN32 AND NOT BUILD_SHARED_LIBS AND NOT COUNTLY_USE_CUSTOM_HTTP)
message(FATAL_ERROR "You must provide a custom HTTP function when compiling statically.")
endif()
Expand Down Expand Up @@ -53,13 +61,16 @@ target_link_libraries(countly Threads::Threads)

target_include_directories(countly PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/vendor/json/include)
if (COUNTLY_BUILD_TESTS)
message("Compiling definitions for tests")
target_compile_definitions(countly PRIVATE COUNTLY_BUILD_TESTS)
endif()

if (COUNTLY_USE_CUSTOM_SHA256)
message("Compiling definitions for custom sha256")
target_compile_definitions(countly PRIVATE COUNTLY_USE_CUSTOM_SHA256)
else()
if (APPLE)
message("Setting openssl root for Mac")
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif()
find_package(OpenSSL REQUIRED)
Expand All @@ -68,14 +79,17 @@ target_link_libraries(countly ${OPENSSL_LIBRARIES})
endif()

if(COUNTLY_USE_CUSTOM_HTTP)
message("Will compile definitions for custom http")
target_compile_definitions(countly PRIVATE COUNTLY_USE_CUSTOM_HTTP)
elseif(NOT WIN32)
message("Checking url as device is not windows")
find_package(CURL REQUIRED)
target_include_directories(countly PRIVATE ${CURL_INCLUDE_DIRS})
target_link_libraries(countly ${CURL_LIBRARIES})
endif()

if(COUNTLY_USE_SQLITE)
message("Building sqlite directories")
target_compile_definitions(countly PRIVATE COUNTLY_USE_SQLITE)
set(Sqlite3_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/sqlite/build)
find_package(Sqlite3)
Expand All @@ -84,6 +98,7 @@ if(COUNTLY_USE_SQLITE)
endif()

if(COUNTLY_BUILD_TESTS)
message("Building test directories")
add_executable(countly-tests
${CMAKE_CURRENT_SOURCE_DIR}/tests/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tests/views.cpp
Expand All @@ -94,10 +109,12 @@ if(COUNTLY_BUILD_TESTS)

target_compile_definitions(countly-tests PRIVATE COUNTLY_BUILD_TESTS)
if(COUNTLY_USE_SQLITE)
message("Compiling definitions for sqlite")
target_compile_definitions(countly-tests PRIVATE COUNTLY_USE_SQLITE)
target_include_directories(countly-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/sqlite)
endif()
if(COUNTLY_USE_CUSTOM_SHA256)
message("Compiling definitions for custom sha256")
target_compile_definitions(countly-tests PRIVATE COUNTLY_USE_CUSTOM_SHA256)
endif()
target_include_directories(countly-tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/doctest/doctest)
Expand All @@ -110,6 +127,7 @@ if(COUNTLY_BUILD_TESTS)
endif()

if(COUNTLY_BUILD_SAMPLE)
message("Building sample directories")
add_executable(countly-sample
${CMAKE_CURRENT_SOURCE_DIR}/examples/example_integration.cpp)

Expand Down
1 change: 1 addition & 0 deletions include/countly/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <random>
#include <sstream>
#include <string>
#include <climits>
#include "nlohmann/json.hpp"

#define COUNTLY_SDK_NAME "cpp-native-unknown"
Expand Down
19 changes: 19 additions & 0 deletions src/countly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,25 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) {
void Countly::start(const std::string &app_key, const std::string &host, int port, bool start_thread) {
mutex->lock();
log(LogLevel::INFO, "[Countly][start]");

#ifdef COUNTLY_USE_SQLITE
log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_SQLITE' is defined");
#else
log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_SQLITE' is not defined");
#endif

#ifdef COUNTLY_USE_CUSTOM_HTTP
log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_HTTP' is defined");
#else
log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_HTTP' is not defined");
#endif

#ifdef COUNTLY_USE_CUSTOM_SHA256
log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_SHA256' is defined");
#else
log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_SHA256' is not defined");
#endif

enable_automatic_session = start_thread;
start_thread = true;

Expand Down

0 comments on commit 72c8deb

Please sign in to comment.