Skip to content

Commit

Permalink
Use vcpkg for most dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
vktr committed Apr 16, 2021
1 parent f323189 commit 1b4df3d
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 232,943 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,19 @@ jobs:
git fetch --prune --unshallow
git submodule update --init --recursive
- name: Install dependencies
run: |
if ('${{ matrix.arch }}' -eq 'x64') {
choco install openssl --no-progress
} elseif ('${{ matrix.arch }}' -eq 'x86') {
choco install openssl --no-progress --x86
}
dotnet tool restore
- name: Setup vcpkg
run: .\vendor\vcpkg\bootstrap-vcpkg.bat

- name: Set environment variables
- name: Install vcpkg ports
run: |
echo "BOOST_ROOT=$env:BOOST_ROOT_1_72_0" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if ('${{ matrix.arch }}' -eq 'x64') {
echo "OPENSSL_ROOT_DIR=$env:ProgramFiles\OpenSSL-Win64" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
} elseif ('${{ matrix.arch }}' -eq 'x86') {
echo "OPENSSL_ROOT_DIR=${env:ProgramFiles(x86)}\OpenSSL-Win32" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
}
.\vendor\vcpkg\vcpkg.exe install boost-log:${{ matrix.arch }}-windows-static-md
.\vendor\vcpkg\vcpkg.exe install fmt:${{ matrix.arch }}-windows-static-md
.\vendor\vcpkg\vcpkg.exe install libtorrent:${{ matrix.arch }}-windows-static-md
.\vendor\vcpkg\vcpkg.exe install nlohmann-json:${{ matrix.arch }}-windows-static-md
.\vendor\vcpkg\vcpkg.exe install sqlite3:${{ matrix.arch }}-windows-static-md
- name: Restore .NET tools
run: dotnet tool restore

- name: Build
run: dotnet cake --platform=${{ matrix.arch }} --target=Publish
Expand Down
12 changes: 3 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
[submodule "vendor/libtorrent"]
path = vendor/libtorrent
url = https://github.com/arvidn/libtorrent
[submodule "vendor/wx"]
path = vendor/wx
url = https://github.com/wxWidgets/wxWidgets
[submodule "vendor/duktape"]
[submodule "vendor/fmt"]
path = vendor/fmt
url = https://github.com/fmtlib/fmt
[submodule "vendor/nlohmann-json"]
path = vendor/nlohmann-json
url = https://github.com/nlohmann/json
[submodule "vendor/crashpad"]
path = vendor/crashpad
url = https://github.com/picotorrent/crashpad
Expand All @@ -20,3 +11,6 @@
[submodule "vendor/antlr4"]
path = vendor/antlr4
url = https://github.com/antlr/antlr4
[submodule "vendor/vcpkg"]
path = vendor/vcpkg
url = https://github.com/picotorrent/vcpkg
76 changes: 21 additions & 55 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1,40 @@
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
cmake_policy(SET CMP0092 NEW) # don't add /W3 as default
cmake_policy(SET CMP0115 OLD) # Source file extensions must be explicit.

set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE STRING "Vcpkg toolchain file")

project("PicoTorrent")

include(cmake/Git.cmake)
include(cmake/GitVersion.cmake)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(Boost_USE_STATIC_LIBS ON)
set(OPENSSL_USE_STATIC_LIBS TRUE)

if(DEFINED ENV{OPENSSL_ROOT_DIR})
set(OPENSSL_ROOT_DIR $ENV{OPENSSL_ROOT_DIR})
message("Using OpenSSL dir from env variable: ${OPENSSL_ROOT_DIR}")
endif()

# --------- antlr4 options
option(WITH_STATIC_CRT "" Off)
# -----------------------

# --------- libtorrent options
option(BUILD_SHARED_LIBS "" off)
option(deprecated-functions "" off)

# uncomment here when webtorrent support is usable
# option(webtorrent "" ON)

# deep inside libtorrent we need to turn off a nlohmann-json dependency
option(NO_EXAMPLES "" ON)

# ----------------------------

# --------- nlohmann-json options
set(JSON_BuildTests OFF CACHE INTERNAL "")
# ---------

# --------- wx options
set(wxUSE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
set(wxBUILD_SHARED OFF CACHE BOOL "" FORCE)
set(wxBUILD_COMPATIBILITY "3.1" CACHE STRING "" FORCE)
set(wxUSE_EXCEPTIONS OFF CACHE BOOL "" FORCE)
# --------------------

find_package(Boost REQUIRED COMPONENTS log)

# vendor libs
add_subdirectory(vendor/fmt)
add_subdirectory(vendor/libtorrent)
add_subdirectory(vendor/nlohmann-json)
add_subdirectory(vendor/sentry-crashpad)
add_subdirectory(vendor/wx)

# pico components
add_subdirectory(src/pql)

# vcpkg packages
find_package(Boost REQUIRED COMPONENTS log)
find_package(fmt CONFIG REQUIRED)
find_package(LibtorrentRasterbar CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
find_package(unofficial-sqlite3 CONFIG REQUIRED)

gitversion_install()
gitversion_showvariable(BranchName GITVERSION_VAR_BRANCHNAME)
gitversion_showvariable(MajorMinorPatch GITVERSION_VAR_VERSION)
Expand All @@ -63,10 +45,7 @@ gitversion_showvariable(SemVer GITVERSION_VAR_SEMVER)
gitversion_showvariable(ShortSha GITVERSION_VAR_SHORTSHA)

# Get git commitish from dependencies
git_abbreviated_hash(${CMAKE_SOURCE_DIR}/vendor/fmt PICO_FMT_GIT_COMMITISH)
git_abbreviated_hash(${CMAKE_SOURCE_DIR}/vendor/libtorrent PICO_LIBTORRENT_GIT_COMMITISH)
git_abbreviated_hash(${CMAKE_SOURCE_DIR}/vendor/nlohmann-json PICO_NLOHMANN_JSON_GIT_COMMITISH)
git_abbreviated_hash(${CMAKE_SOURCE_DIR}/vendor/wx PICO_WX_GIT_COMMITISH)
git_abbreviated_hash(${CMAKE_SOURCE_DIR}/vendor/wx PICO_WX_GIT_COMMITISH)

# Generate buildinfo file
configure_file("${CMAKE_SOURCE_DIR}/src/picotorrent/buildinfo.cpp.in" "${CMAKE_SOURCE_DIR}/src/picotorrent/buildinfo.cpp" @ONLY)
Expand All @@ -79,18 +58,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /MAP /OPT:REF /OPT:ICF")
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /MAP /OPT:REF /OPT:ICF")

add_library(
sqlite
STATIC
src/sqlite/sqlite3
)

target_include_directories(
sqlite
INTERFACE
src/sqlite
)

add_executable(
PicoTorrent-coredb
src/l10n/main
Expand Down Expand Up @@ -124,7 +91,7 @@ target_link_libraries(
PicoTorrent-coredb
PRIVATE
nlohmann_json::nlohmann_json
sqlite
unofficial::sqlite3::sqlite3
)

add_executable(
Expand Down Expand Up @@ -226,9 +193,6 @@ target_compile_definitions(
-DPICO_VERSION_MINOR=${GITVERSION_VAR_VERSION_MINOR}
-DPICO_VERSION_PATCH=${GITVERSION_VAR_VERSION_PATCH}

-DPICO_FMT_GIT_COMMITISH=${PICO_FMT_GIT_COMMITISH}
-DPICO_LIBTORRENT_GIT_COMMITISH=${PICO_LIBTORRENT_GIT_COMMITISH}
-DPICO_NLOHMANN_JSON_GIT_COMMITISH=${PICO_NLOHMANN_JSON_GIT_COMMITISH}
-DPICO_WX_GIT_COMMITISH=${PICO_WX_GIT_COMMITISH}
)

Expand All @@ -246,7 +210,9 @@ target_link_libraries(

PRIVATE

${Boost_LIBRARIES}
# boost
Boost::boost
Boost::log

# wxWidgets
wxcore wxbase wxpropgrid
Expand All @@ -267,18 +233,18 @@ target_link_libraries(
mini_chromium

# fmt
fmt
fmt::fmt

# nlohmann-json
nlohmann_json::nlohmann_json

# Rasterbar-libtorrent
"torrent-rasterbar"
LibtorrentRasterbar::torrent-rasterbar

# PQL
PicoTorrentPQL

sqlite
unofficial::sqlite3::sqlite3
)

set_property(TARGET PicoTorrent PROPERTY ENABLE_EXPORTS 1)
Expand Down
6 changes: 5 additions & 1 deletion build.cake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ Task("Generate-Project")
OutputPath = OutputDirectory,
Generator = "Visual Studio 16 2019",
Platform = platform == "x86" ? "Win32" : "x64",
Toolset = "v142"
Toolset = "v142",
Options = new []
{
"-DVCPKG_TARGET_TRIPLET=x64-windows-static-md"
}
});
});

Expand Down
6 changes: 3 additions & 3 deletions src/picotorrent/ui/dialogs/aboutdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ AboutDialog::AboutDialog(wxWindow* parent, wxWindowID id)

lv->InsertItem(lv->GetItemCount(), "fmt");
lv->SetItem(lv->GetItemCount() - 1, 1, fmtVersion.str());
lv->SetItem(lv->GetItemCount() - 1, 2, BOOST_STRINGIZE(PICO_FMT_GIT_COMMITISH));
lv->SetItem(lv->GetItemCount() - 1, 2, "-");

lv->InsertItem(lv->GetItemCount(), "nlohmann-json");
lv->SetItem(lv->GetItemCount() - 1, 1, nljson.str());
lv->SetItem(lv->GetItemCount() - 1, 2, BOOST_STRINGIZE(PICO_NLOHMANN_JSON_GIT_COMMITISH));
lv->SetItem(lv->GetItemCount() - 1, 2, "-");

lv->InsertItem(lv->GetItemCount(), OPENSSL_VERSION_TEXT);
lv->SetItem(lv->GetItemCount() - 1, 1, "-");
Expand All @@ -68,7 +68,7 @@ AboutDialog::AboutDialog(wxWindow* parent, wxWindowID id)

lv->InsertItem(lv->GetItemCount(), "Rasterbar-libtorrent");
lv->SetItem(lv->GetItemCount() - 1, 1, LIBTORRENT_VERSION);
lv->SetItem(lv->GetItemCount() - 1, 2, BOOST_STRINGIZE(PICO_LIBTORRENT_GIT_COMMITISH));
lv->SetItem(lv->GetItemCount() - 1, 2, "-");

lv->InsertItem(lv->GetItemCount(), "SQLite");
lv->SetItem(lv->GetItemCount() - 1, 1, SQLITE_VERSION);
Expand Down
2 changes: 1 addition & 1 deletion src/picotorrent/ui/dialogs/listeninterfacedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ std::string ListenInterfaceDialog::GetAddress()

int ListenInterfaceDialog::GetPort()
{
return std::atoi(m_port->GetValue());
return std::atoi(m_port->GetValue().c_str());
}

void ListenInterfaceDialog::LoadAdapters()
Expand Down
4 changes: 2 additions & 2 deletions src/picotorrent/ui/dialogs/preferencesconnectionpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ PreferencesConnectionPage::PreferencesConnectionPage(wxWindow* parent, std::shar
if (sel < 0) { return; }

std::string address = m_listenInterfaces->GetItemText(sel);
int port = std::atoi(m_listenInterfaces->GetItemText(sel, 1));
int port = std::atoi(m_listenInterfaces->GetItemText(sel, 1).c_str());

ListenInterfaceDialog dlg(this, wxID_ANY, address, port);

Expand Down Expand Up @@ -210,7 +210,7 @@ void PreferencesConnectionPage::Save(bool* restartRequired)
Core::Configuration::ListenInterface li;
li.address = m_listenInterfaces->GetItemText(i, 0);
li.id = reinterpret_cast<Item*>(m_listenInterfaces->GetItemData(i))->id;
li.port = std::atoi(m_listenInterfaces->GetItemText(i, 1));
li.port = std::atoi(m_listenInterfaces->GetItemText(i, 1).c_str());

m_cfg->UpsertListenInterface(li);
}
Expand Down
Loading

0 comments on commit 1b4df3d

Please sign in to comment.