Skip to content
Closed
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
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ README.md eol=lf
CMakeLists.txt eol=lf
docs/Doxyfile eol=lf
docs/*.png binary
docs/*.css eol=lf linguist-vendored=true
docs/*.html eol=lf linguist-vendored=true
**/*.cmake eol=lf
**/*.cpp eol=lf
Expand Down
21 changes: 18 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
**/*.deb
**/*.rpm
**/*.exe
**/*.obj
*.cmake
.idea

cmake-build-debug/
CMakePresets.json

.vscode/
include/dpp/
build/
deps/
docs/html/
include/cpp-httplib/
include/drogon/
include/nlohmann/
**/build/
**/*.dll
**/*.lib
docs/html/

cpp-httplib/
json/

conan_toolchain.cmake
*conan*.bat
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "docs/doxygen-awesome-css"]
path = docs/doxygen-awesome-css
url = https://github.com/jothepro/doxygen-awesome-css.git
[submodule "deps/drogon"]
path = deps/drogon
url = https://github.com/drogonframework/drogon.git
113 changes: 99 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
cmake_minimum_required(VERSION 3.8.2)
cmake_minimum_required(VERSION 3.15)

project(
topgg
LANGUAGES CXX
HOMEPAGE_URL "https://docs.top.gg/docs"
DESCRIPTION "The official C++ wrapper for the Top.gg API."
DESCRIPTION "A simple API wrapper for Top.gg written in C++."
)

set(CMAKE_BUILD_TYPE Debug CACHE STRING "Build type")
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")

option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(ENABLE_CORO "Support for C++20 coroutines" OFF)
option(ENABLE_API "Build primary API support" ON)
option(ENABLE_CPP_HTTPLIB_WEBHOOKS "Build support for webhooks via cpp-httplib" OFF)
option(ENABLE_DROGON_WEBHOOKS "Build support for webhooks via drogon" OFF)
option(ENABLE_CORO "Add support for C++20 coroutines" OFF)
option(TESTING "Enable this only if you are testing the library" OFF)

if(ENABLE_API)
file(GLOB TOPGG_SOURCE_FILES src/*.cpp)
endif()

if(ENABLE_CPP_HTTPLIB_WEBHOOKS)
set(TOPGG_SOURCE_FILES ${TOPGG_SOURCE_FILES} src/webhooks/cpp-httplib.cpp src/webhooks/models.cpp)
elseif(ENABLE_DROGON_WEBHOOKS)
set(TOPGG_SOURCE_FILES ${TOPGG_SOURCE_FILES} src/webhooks/drogon.cpp src/webhooks/models.cpp)
endif()

if(BUILD_SHARED_LIBS)
add_library(topgg SHARED ${TOPGG_SOURCE_FILES})

if(WIN32)
target_sources(topgg PRIVATE ${CMAKE_SOURCE_DIR}/topgg.rc)
target_sources(topgg PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/topgg.rc)
target_compile_definitions(topgg PRIVATE __TOPGG_BUILDING_DLL__)
endif()
else()
add_library(topgg STATIC ${TOPGG_SOURCE_FILES})
endif()

if(WIN32)
target_compile_definitions(topgg PRIVATE $<$<BOOL:${BUILD_SHARED_LIBS}>:__TOPGG_BUILDING_DLL__:DPP_STATIC TOPGG_STATIC>)
target_compile_definitions(topgg PUBLIC DPP_STATIC TOPGG_STATIC)
endif()
endif()

if(ENABLE_CORO)
Expand All @@ -34,26 +50,95 @@ else()
set(TOPGG_CXX_STANDARD 17)
endif()

if(TESTING)
target_compile_definitions(topgg PUBLIC __TOPGG_TESTING__)
endif()

set_target_properties(topgg PROPERTIES
OUTPUT_NAME topgg
CXX_STANDARD ${TOPGG_CXX_STANDARD}
CXX_STANDARD_REQUIRED ON
)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(ENABLE_API)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(DPP REQUIRED)
endif()

if(ENABLE_CPP_HTTPLIB_WEBHOOKS)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib/cpp-httplib.h")
execute_process(COMMAND git clone https://github.com/yhirose/cpp-httplib.git --depth 1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib")
endif()
file(RENAME "${CMAKE_CURRENT_SOURCE_DIR}/cpp-httplib/httplib.h" "${CMAKE_CURRENT_SOURCE_DIR}/include/cpp-httplib/cpp-httplib.h")
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/cpp-httplib")
endif()

if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann/json.hpp")
execute_process(COMMAND git clone https://github.com/nlohmann/json.git --depth 1 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann")
file(MAKE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann")
endif()
file(RENAME "${CMAKE_CURRENT_SOURCE_DIR}/json/single_include/nlohmann/json.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/include/nlohmann/json.hpp")
file(REMOVE_RECURSE "${CMAKE_CURRENT_SOURCE_DIR}/json")
endif()
endif()

if(ENABLE_DROGON_WEBHOOKS)
if(WIN32)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_SOURCE_DIR}/conan_toolchain.cmake")

include(${CMAKE_CURRENT_SOURCE_DIR}/conan_toolchain.cmake)
endif()

set(DROGON_LIBRARY drogon)

set(
TRANTOR_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/trantor"
"${CMAKE_BINARY_DIR}/deps/drogon/trantor/exports"
)

set(
DROGON_INCLUDE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/lib/inc"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/orm_lib/inc"
"${CMAKE_CURRENT_SOURCE_DIR}/deps/drogon/nosql_lib/redis/inc"
"${CMAKE_BINARY_DIR}/deps/drogon/exports"
)

set(BUILD_CTL OFF)
set(BUILD_EXAMPLES OFF)
set(BUILD_BROTLI OFF)
set(BUILD_YAML_CONFIG OFF)
set(USE_SUBMODULE ON)

add_subdirectory(deps/drogon)

target_compile_definitions(topgg PUBLIC __TOPGG_DROGON_WEBHOOKS__)

if(WIN32)
target_compile_definitions(topgg PRIVATE _CRT_SECURE_NO_WARNINGS)
cmake_policy(SET CMP0091 NEW)
endif()
endif()

target_compile_definitions(topgg PRIVATE __TOPGG_BUILDING__)

if(MSVC)
target_compile_options(topgg PUBLIC $<$<CONFIG:Debug>:/diagnostics:caret /MTd> $<$<CONFIG:Release>:/MT /O2 /Oi /Oy /Gy>)
target_compile_options(topgg PRIVATE /nologo $<$<CONFIG:Debug>:/diagnostics:caret /MDd /DDEBUG /D_DEBUG> $<$<CONFIG:Release>:/MD /O2 /Oi /Oy /Gy /DNDEBUG>)
else()
target_compile_options(topgg PUBLIC $<$<CONFIG:Release>:-O3> -Wall -Wextra -Wpedantic -Wformat=2 -Wnull-dereference -Wuninitialized -Wdeprecated)
target_compile_options(topgg PRIVATE $<$<CONFIG:Release>:-O3> -Wall -Wextra -Wpedantic -Wformat=2 -Wnull-dereference -Wuninitialized -Wdeprecated)
endif()

target_include_directories(topgg PUBLIC
${CMAKE_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
${DPP_INCLUDE_DIR}
${JSONCPP_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIR}
${TRANTOR_INCLUDE_DIR}
${DROGON_INCLUDE_DIR}
)

target_link_libraries(topgg ${DPP_LIBRARIES})
target_link_libraries(topgg PUBLIC ${DPP_LIBRARIES} ${JSONCPP_LIBRARIES} ${DROGON_LIBRARY})
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Top.gg & null8626
Copyright (c) 2024-2025 Top.gg & null8626

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 6 additions & 4 deletions cmake/FindDPP.cmake
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
if(WIN32 AND NOT EXISTS ${CMAKE_SOURCE_DIR}/deps/dpp.lib)
get_filename_component(CMAKE_CURRENT_LIST_DIRECTORY "${CMAKE_CURRENT_LIST_FILE}" PATH)

if(WIN32 AND NOT EXISTS ${CMAKE_CURRENT_LIST_DIRECTORY}/../deps/dpp.lib)
string(TOLOWER ${CMAKE_BUILD_TYPE} INSTALL_DPP_BUILD_TYPE)
execute_process(COMMAND powershell "-NoLogo" "-NoProfile" "-File" ".\\install_dpp_msvc.ps1" ${INSTALL_DPP_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
execute_process(COMMAND powershell "-NoLogo" "-NoProfile" "-File" "${CMAKE_CURRENT_LIST_DIRECTORY}/../install_dpp_msvc.ps1" ${INSTALL_DPP_BUILD_TYPE} WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIRECTORY}/..")
endif()

if(APPLE)
find_path(DPP_INCLUDE_DIR NAMES dpp/dpp.h HINTS "/opt/homebrew/include")
find_library(DPP_LIBRARIES NAMES dpp "libdpp.a" HINTS "/opt/homebrew/lib")
else()
find_path(DPP_INCLUDE_DIR NAMES dpp/dpp.h HINTS ${CMAKE_SOURCE_DIR}/include)
find_library(DPP_LIBRARIES NAMES dpp "libdpp.a" HINTS ${CMAKE_SOURCE_DIR}/deps)
find_path(DPP_INCLUDE_DIR NAMES dpp/dpp.h HINTS ${CMAKE_CURRENT_LIST_DIRECTORY}/../include)
find_library(DPP_LIBRARIES NAMES dpp "libdpp.a" HINTS ${CMAKE_CURRENT_LIST_DIRECTORY}/../deps)
endif()

include(FindPackageHandleStandardArgs)
Expand Down
3 changes: 3 additions & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[requires]
jsoncpp/1.9.4
zlib/1.2.11
1 change: 1 addition & 0 deletions deps/drogon
Submodule drogon added at 065899
7 changes: 3 additions & 4 deletions docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ PROJECT_NAME = "Top.gg C++ SDK"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.0.0
PROJECT_NUMBER = 3.0.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "The official C++ wrapper for the Top.gg API."
PROJECT_BRIEF = "A simple API wrapper for Top.gg written in C++."

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand Down Expand Up @@ -1348,8 +1348,7 @@ HTML_STYLESHEET =
# This tag requires that the tag GENERATE_HTML is set to YES.

HTML_EXTRA_STYLESHEET = doxygen-awesome-css/doxygen-awesome.css \
doxygen-awesome-css/doxygen-awesome-sidebar-only.css \
style.css
doxygen-awesome-css/doxygen-awesome-sidebar-only.css

# The HTML_EXTRA_FILES tag can be used to specify one or more extra images or
# other source files which should be copied to the HTML output directory. Note
Expand Down
4 changes: 2 additions & 2 deletions docs/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<meta property="og:title" content="Top.gg C++ SDK">
<meta property="og:description" content="The official C++ wrapper for the Top.gg API.">
<meta name="description" content="The official C++ wrapper for the Top.gg API.">
<meta property="og:description" content="A simple API wrapper for Top.gg written in C++.">
<meta name="description" content="A simple API wrapper for Top.gg written in C++.">
<meta property="og:url" content="https://docs.top.gg/docs/">
<meta property="og:type" content="website">
<meta property="twitter:title" content="Top.gg C++ SDK">
Expand Down
58 changes: 0 additions & 58 deletions docs/style.css

This file was deleted.

Loading