mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-03 08:15:35 +00:00
let's try vcpkg
This commit is contained in:
parent
3b2016d09f
commit
8d7505956d
126
CMakeLists.txt
126
CMakeLists.txt
@ -1,5 +1,17 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
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 \
|
message(STATUS "You can find build instructions and a list of dependencies in the README at \
|
||||||
https://github.com/BeamMP/BeamMP-Server")
|
https://github.com/BeamMP/BeamMP-Server")
|
||||||
|
|
||||||
@ -10,15 +22,6 @@ project(BeamMP-Server
|
|||||||
|
|
||||||
set(HTTPLIB_REQUIRE_OPENSSL ON)
|
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)
|
add_compile_definitions(CPPHTTPLIB_OPENSSL_SUPPORT)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
@ -36,26 +39,6 @@ if (WIN32)
|
|||||||
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||||
endif()
|
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)
|
if (MSVC)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /bigobj")
|
||||||
endif ()
|
endif ()
|
||||||
@ -81,7 +64,19 @@ elseif (UNIX)
|
|||||||
endif (SANITIZE)
|
endif (SANITIZE)
|
||||||
endif ()
|
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)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
@ -113,57 +108,34 @@ add_executable(BeamMP-Server
|
|||||||
target_compile_definitions(BeamMP-Server PRIVATE SECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}")
|
target_compile_definitions(BeamMP-Server PRIVATE SECRET_SENTRY_URL="${BEAMMP_SECRET_SENTRY_URL}")
|
||||||
include_directories(BeamMP-Server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
include_directories(BeamMP-Server PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
|
||||||
target_include_directories(BeamMP-Server PUBLIC
|
include(FindThreads)
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/include"
|
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/commandline")
|
|
||||||
|
|
||||||
if (APPLE)
|
find_package(OpenSSL REQUIRED)
|
||||||
message(STATUS "NOT looking for Lua on APPLE")
|
find_package(ZLIB REQUIRED)
|
||||||
else()
|
find_package(CURL CONFIG REQUIRED)
|
||||||
message(STATUS "Looking for Lua")
|
find_package(Lua REQUIRED 5.3)
|
||||||
find_package(Lua REQUIRED VERSION 5.3)
|
find_package(nlohmann_json CONFIG REQUIRED)
|
||||||
endif()
|
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")
|
||||||
|
|
||||||
target_include_directories(BeamMP-Server PUBLIC
|
target_include_directories(BeamMP-Server PRIVATE
|
||||||
|
${CPP_HTTPLIB_INCLUDE_DIRS}
|
||||||
${LUA_INCLUDE_DIR}
|
${LUA_INCLUDE_DIR}
|
||||||
${CURL_INCLUDE_DIRS}
|
)
|
||||||
"include/tomlplusplus"
|
|
||||||
"include/sentry-native/include"
|
|
||||||
"include/curl/include")
|
|
||||||
|
|
||||||
message(STATUS "Looking for SSL")
|
target_link_libraries(BeamMP-Server PRIVATE OpenSSL::SSL OpenSSL::Crypto
|
||||||
|
|
||||||
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
|
ZLIB::ZLIB
|
||||||
|
CURL::libcurl
|
||||||
${LUA_LIBRARIES}
|
${LUA_LIBRARIES}
|
||||||
${OPENSSL_LIBRARIES}
|
Threads::Threads
|
||||||
commandline
|
commandline
|
||||||
sentry)
|
nlohmann_json::nlohmann_json
|
||||||
endif ()
|
rapidjson
|
||||||
|
sentry::sentry
|
||||||
|
sol2::sol2
|
||||||
|
toml11::toml11
|
||||||
|
)
|
||||||
|
|
||||||
|
7
deps/CMakeLists.txt
vendored
7
deps/CMakeLists.txt
vendored
@ -1,9 +1,4 @@
|
|||||||
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")
|
include_directories("${PROJECT_SOURCE_DIR}/deps")
|
||||||
|
include_directories("${PROJECT_SOURCE_DIR}/deps/commandline")
|
||||||
|
|
||||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/commandline")
|
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/commandline")
|
||||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/sol2")
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
#define TOML11_PRESERVE_COMMENTS_BY_DEFAULT
|
#define TOML11_PRESERVE_COMMENTS_BY_DEFAULT
|
||||||
#include <toml11/toml.hpp> // header-only version of TOML++
|
#include <toml.hpp> // header-only version of TOML++
|
||||||
|
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <toml11/toml.hpp>
|
#include <toml.hpp>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -72,7 +72,7 @@ void TSentry::Log(SentryLevel level, const std::string& logger, const std::strin
|
|||||||
SetContext("threads", { { "thread-name", ThreadName(true) } });
|
SetContext("threads", { { "thread-name", ThreadName(true) } });
|
||||||
auto Msg = sentry_value_new_message_event(sentry_level_t(level), logger.c_str(), text.c_str());
|
auto Msg = sentry_value_new_message_event(sentry_level_t(level), logger.c_str(), text.c_str());
|
||||||
sentry_capture_event(Msg);
|
sentry_capture_event(Msg);
|
||||||
sentry_remove_transaction();
|
sentry_set_transaction(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TSentry::LogError(const std::string& text, const std::string& file, const std::string& line) {
|
void TSentry::LogError(const std::string& text, const std::string& file, const std::string& line) {
|
||||||
|
18
vcpkg.cmake
Normal file
18
vcpkg.cmake
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
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")
|
17
vcpkg.json
Normal file
17
vcpkg.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user