From 758d5b2c968d0301d01fe3fb1e573e547bedfd03 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Sun, 29 May 2022 14:37:50 +0200 Subject: [PATCH] Revert "let's try vcpkg" This reverts commit 8d7505956d86fbbd5b1f7496af2b413b360afa09. --- CMakeLists.txt | 132 ++++++++++++++++++++++++++----------------- deps/CMakeLists.txt | 7 ++- include/TConfig.h | 2 +- include/TLuaEngine.h | 2 +- src/TSentry.cpp | 2 +- vcpkg.cmake | 18 ------ vcpkg.json | 17 ------ 7 files changed, 89 insertions(+), 91 deletions(-) delete mode 100644 vcpkg.cmake delete mode 100644 vcpkg.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 680cd8b..f6a813f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 () diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 6f87000..4e556b0 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -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") diff --git a/include/TConfig.h b/include/TConfig.h index b05f422..3fcc597 100644 --- a/include/TConfig.h +++ b/include/TConfig.h @@ -5,7 +5,7 @@ #include #define TOML11_PRESERVE_COMMENTS_BY_DEFAULT -#include // header-only version of TOML++ +#include // header-only version of TOML++ namespace fs = std::filesystem; diff --git a/include/TLuaEngine.h b/include/TLuaEngine.h index 876d910..5ca2222 100644 --- a/include/TLuaEngine.h +++ b/include/TLuaEngine.h @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/TSentry.cpp b/src/TSentry.cpp index 7f2b416..da05c10 100644 --- a/src/TSentry.cpp +++ b/src/TSentry.cpp @@ -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) { diff --git a/vcpkg.cmake b/vcpkg.cmake deleted file mode 100644 index 56b51e5..0000000 --- a/vcpkg.cmake +++ /dev/null @@ -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") diff --git a/vcpkg.json b/vcpkg.json deleted file mode 100644 index f28fa5b..0000000 --- a/vcpkg.json +++ /dev/null @@ -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" - ] -}