Revert "let's try vcpkg"

This reverts commit 8d7505956d86fbbd5b1f7496af2b413b360afa09.
This commit is contained in:
Lion Kortlepel 2022-05-29 14:37:50 +02:00
parent 1970d97ea4
commit 758d5b2c96
No known key found for this signature in database
GPG Key ID: 4322FF2B4C71259B
7 changed files with 89 additions and 91 deletions

View File

@ -1,17 +1,5 @@
cmake_minimum_required(VERSION 3.0)
if (WIN32)
set(VCPKG_TARGET_TRIPLET "x64-windows-static")
elseif(UNIX)
set(VCPKG_TARGET_TRIPLET "x64-linux")
endif()
option(USE_VCPKG "USE_VCPKG" ON)
if(USE_VCPKG)
include(vcpkg.cmake)
endif()
message(STATUS "You can find build instructions and a list of dependencies in the README at \
https://github.com/BeamMP/BeamMP-Server")
@ -22,6 +10,15 @@ project(BeamMP-Server
set(HTTPLIB_REQUIRE_OPENSSL ON)
include_directories("${PROJECT_SOURCE_DIR}/deps/asio/asio/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/rapidjson/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/websocketpp")
include_directories("${PROJECT_SOURCE_DIR}/deps/commandline")
include_directories("${PROJECT_SOURCE_DIR}/deps/sol2/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/cpp-httplib")
include_directories("${PROJECT_SOURCE_DIR}/deps/json/single_include")
include_directories("${PROJECT_SOURCE_DIR}/deps")
add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT)
if(APPLE)
@ -39,6 +36,26 @@ if (WIN32)
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
endif()
include_directories("include/sentry-native/include")
set(SENTRY_BUILD_SHARED_LIBS OFF)
if (MSVC)
set(SENTRY_BUILD_RUNTIMESTATIC ON)
endif()
message(STATUS "Checking for Sentry URL")
# this is set by the build system.
# IMPORTANT: if you're building from source, just leave this empty
if (NOT DEFINED BEAMMP_SECRET_SENTRY_URL)
message(WARNING "No sentry URL configured. Sentry logging is disabled for this build. \
This is not an error, and if you're building the BeamMP-Server yourself, this is expected and can be ignored.")
set(BEAMMP_SECRET_SENTRY_URL "")
set(SENTRY_BACKEND none)
else()
string(LENGTH ${BEAMMP_SECRET_SENTRY_URL} URL_LEN)
message(STATUS "Sentry URL is length ${URL_LEN}")
set(SENTRY_BACKEND breakpad)
endif()
add_subdirectory("deps/sentry-native")
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
endif ()
@ -64,19 +81,7 @@ elseif (UNIX)
endif (SANITIZE)
endif ()
message(STATUS "Checking for Sentry URL")
# this is set by the build system.
# IMPORTANT: if you're building from source, just leave this empty
if (NOT DEFINED BEAMMP_SECRET_SENTRY_URL)
message(WARNING "No sentry URL configured. Sentry logging is disabled for this build. \
This is not an error, and if you're building the BeamMP-Server yourself, this is expected and can be ignored.")
set(BEAMMP_SECRET_SENTRY_URL "")
set(SENTRY_BACKEND none)
else()
string(LENGTH ${BEAMMP_SECRET_SENTRY_URL} URL_LEN)
message(STATUS "Sentry URL is length ${URL_LEN}")
set(SENTRY_BACKEND breakpad)
endif()
set(CMAKE_CXX_STANDARD 17)
@ -108,34 +113,57 @@ add_executable(BeamMP-Server
target_compile_definitions(BeamMP-Server PRIVATE SECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}")
include_directories(BeamMP-Server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
include(FindThreads)
target_include_directories(BeamMP-Server PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/commandline")
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(Lua REQUIRED 5.3)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(RapidJSON CONFIG REQUIRED)
find_package(sentry CONFIG REQUIRED)
find_package(sol2 CONFIG REQUIRED)
find_package(toml11 CONFIG REQUIRED)
find_path(CPP_HTTPLIB_INCLUDE_DIRS "httplib.h")
if (APPLE)
message(STATUS "NOT looking for Lua on APPLE")
else()
message(STATUS "Looking for Lua")
find_package(Lua REQUIRED VERSION 5.3)
endif()
target_include_directories(BeamMP-Server PRIVATE
${CPP_HTTPLIB_INCLUDE_DIRS}
${LUA_INCLUDE_DIR}
)
target_include_directories(BeamMP-Server PUBLIC
${LUA_INCLUDE_DIR}
${CURL_INCLUDE_DIRS}
"include/tomlplusplus"
"include/sentry-native/include"
"include/curl/include")
target_link_libraries(BeamMP-Server PRIVATE OpenSSL::SSL OpenSSL::Crypto
ZLIB::ZLIB
CURL::libcurl
${LUA_LIBRARIES}
Threads::Threads
commandline
nlohmann_json::nlohmann_json
rapidjson
sentry::sentry
sol2::sol2
toml11::toml11
)
message(STATUS "Looking for SSL")
if (APPLE)
set(OPENSSL_LIBRARIES ssl crypto)
else()
find_package(OpenSSL REQUIRED)
endif()
target_link_libraries(BeamMP-Server sol2::sol2 ${LUA_LIBRARIES})
message(STATUS "CURL IS ${CURL_LIBRARIES}")
if (UNIX)
target_link_libraries(BeamMP-Server
z
pthread
${LUA_LIBRARIES}
crypto
${OPENSSL_LIBRARIES}
commandline
sentry
ssl)
elseif (WIN32)
include(FindLua)
message(STATUS "Looking for libz")
find_package(ZLIB REQUIRED)
message(STATUS "Looking for RapidJSON")
find_package(RapidJSON CONFIG REQUIRED)
target_include_directories(BeamMP-Server PRIVATE ${RAPIDJSON_INCLUDE_DIRS})
target_link_libraries(BeamMP-Server
ws2_32
ZLIB::ZLIB
${LUA_LIBRARIES}
${OPENSSL_LIBRARIES}
commandline
sentry)
endif ()

7
deps/CMakeLists.txt vendored
View File

@ -1,4 +1,9 @@
include_directories("${PROJECT_SOURCE_DIR}/deps")
include_directories("${PROJECT_SOURCE_DIR}/deps/asio/asio/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/rapidjson/include")
include_directories("${PROJECT_SOURCE_DIR}/deps/websocketpp")
include_directories("${PROJECT_SOURCE_DIR}/deps/commandline")
include_directories("${PROJECT_SOURCE_DIR}/deps/sol2/include")
include_directories("${PROJECT_SOURCE_DIR}/deps")
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/commandline")
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/sol2")

View File

@ -5,7 +5,7 @@
#include <atomic>
#define TOML11_PRESERVE_COMMENTS_BY_DEFAULT
#include <toml.hpp> // header-only version of TOML++
#include <toml11/toml.hpp> // header-only version of TOML++
namespace fs = std::filesystem;

View File

@ -12,7 +12,7 @@
#include <mutex>
#include <queue>
#include <set>
#include <toml.hpp>
#include <toml11/toml.hpp>
#include <unordered_map>
#include <vector>

View File

@ -72,7 +72,7 @@ void TSentry::Log(SentryLevel level, const std::string& logger, const std::strin
SetContext("threads", { { "thread-name", ThreadName(true) } });
auto Msg = sentry_value_new_message_event(sentry_level_t(level), logger.c_str(), text.c_str());
sentry_capture_event(Msg);
sentry_set_transaction(nullptr);
sentry_remove_transaction();
}
void TSentry::LogError(const std::string& text, const std::string& file, const std::string& line) {

View File

@ -1,18 +0,0 @@
include(FetchContent)
message(STATUS "Getting, checking and running vcpkg, this may take a while")
FetchContent_Declare(
vcpkg
GIT_REPOSITORY https://github.com/microsoft/vcpkg.git
)
FetchContent_GetProperties(vcpkg)
if(NOT vcpkg_POPULATED)
FetchContent_Populate(vcpkg)
execute_process(COMMAND ./${vcpkg_SOURCE_DIR}/bootstrap-vcpkg.sh)
endif()
set(CMAKE_TOOLCHAIN_FILE ${vcpkg_SOURCE_DIR}/scripts/buildsystems/vcpkg.cmake
CACHE STRING "Vcpkg toolchain file")

View File

@ -1,17 +0,0 @@
{
"name": "beammp-server",
"version-string": "3.0.2",
"homepage": "https://beammp.com",
"dependencies": [
"sentry-native",
"lua",
"zlib",
"rapidjson",
"nlohmann-json",
"openssl",
"curl",
"sol2",
"cpp-httplib",
"toml11"
]
}