mirror of
https://github.com/TokTok/c-toxcore
synced 2026-03-29 09:39:52 +00:00
chore: Use vcpkg instead of conan in the MSVC build.
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
"cacheVariables": {
|
"cacheVariables": {
|
||||||
"ENABLE_SHARED": true,
|
"ENABLE_SHARED": true,
|
||||||
"ENABLE_STATIC": true,
|
"ENABLE_STATIC": true,
|
||||||
|
"FLAT_OUTPUT_STRUCTURE": true,
|
||||||
"AUTOTEST": true,
|
"AUTOTEST": true,
|
||||||
"BUILD_MISC_TESTS": true,
|
"BUILD_MISC_TESTS": true,
|
||||||
"BOOTSTRAP_DAEMON": false,
|
"BOOTSTRAP_DAEMON": false,
|
||||||
@@ -17,5 +18,19 @@
|
|||||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"buildPresets": [
|
||||||
|
{
|
||||||
|
"name": "windows-default",
|
||||||
|
"configurePreset": "windows-default",
|
||||||
|
"description": "Build for Windows using default settings"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testPresets": [
|
||||||
|
{
|
||||||
|
"name": "windows-default",
|
||||||
|
"configurePreset": "windows-default",
|
||||||
|
"description": "Run tests for Windows using default settings"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
pool:
|
pool:
|
||||||
vmImage: "windows-2019"
|
vmImage: "windows-2019"
|
||||||
jobs:
|
jobs:
|
||||||
- job: "windows_msvc_conan"
|
- job: "vcpkg"
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
static:
|
static:
|
||||||
conan.shared: "False"
|
ENABLE_STATIC: "ON"
|
||||||
|
ENABLE_SHARED: "OFF"
|
||||||
shared:
|
shared:
|
||||||
conan.shared: "True"
|
ENABLE_STATIC: "OFF"
|
||||||
|
ENABLE_SHARED: "ON"
|
||||||
steps:
|
steps:
|
||||||
- bash: choco install pkgconfiglite
|
- task: Cache@2
|
||||||
displayName: "Install pkg-config"
|
inputs:
|
||||||
- bash: python -m pip install conan
|
key: "vcpkg"
|
||||||
displayName: "Install Conan"
|
path: "_build/vcpkg_installed"
|
||||||
- bash: git submodule update --init --recursive
|
- bash: git submodule update --init --recursive
|
||||||
displayName: "Fetch git submodules"
|
- bash: cmake --preset windows-default -DENABLE_STATIC=$(ENABLE_STATIC) -DENABLE_SHARED=$(ENABLE_SHARED)
|
||||||
- bash: conan profile detect
|
env:
|
||||||
displayName: "Detect Conan profile"
|
VCPKG_ROOT: "C:/vcpkg"
|
||||||
- bash: conan build -o "&:with_tests=True" -o "&:shared=$(conan.shared)" .
|
VCPKG_DEFAULT_TRIPLET: "x64-windows"
|
||||||
displayName: "Build with Conan"
|
- bash: cmake --build _build --config Release
|
||||||
|
- bash: ctest --preset windows-default -C Release --parallel 50 ||
|
||||||
|
ctest --preset windows-default -C Release --rerun-failed --output-on-failure
|
||||||
|
|||||||
96
conanfile.py
96
conanfile.py
@@ -1,96 +0,0 @@
|
|||||||
# pylint: disable=not-callable
|
|
||||||
import os
|
|
||||||
import re
|
|
||||||
|
|
||||||
from conan import ConanFile
|
|
||||||
from conan.tools.cmake import CMake
|
|
||||||
from conan.tools.cmake import cmake_layout
|
|
||||||
from conan.tools.cmake import CMakeDeps
|
|
||||||
from conan.tools.cmake import CMakeToolchain
|
|
||||||
from conan.tools.files import collect_libs
|
|
||||||
from conan.tools.files import load
|
|
||||||
|
|
||||||
|
|
||||||
class ToxConan(ConanFile):
|
|
||||||
name = "toxcore"
|
|
||||||
url = "https://tox.chat"
|
|
||||||
description = "The future of online communications."
|
|
||||||
license = "GPL-3.0-only"
|
|
||||||
settings = "os", "compiler", "build_type", "arch"
|
|
||||||
requires = (
|
|
||||||
"libsodium/1.0.20",
|
|
||||||
"opus/1.4",
|
|
||||||
"libvpx/1.14.1",
|
|
||||||
)
|
|
||||||
scm = {"type": "git", "url": "auto", "revision": "auto"}
|
|
||||||
|
|
||||||
options = {
|
|
||||||
"shared": [True, False],
|
|
||||||
"with_tests": [True, False],
|
|
||||||
}
|
|
||||||
default_options = {
|
|
||||||
"shared": False,
|
|
||||||
"with_tests": False,
|
|
||||||
}
|
|
||||||
|
|
||||||
def set_version(self):
|
|
||||||
content = load(self, os.path.join(self.recipe_folder,
|
|
||||||
"CMakeLists.txt"))
|
|
||||||
version_major = re.search(r"set\(PROJECT_VERSION_MAJOR \"(.*)\"\)",
|
|
||||||
content).group(1)
|
|
||||||
version_minor = re.search(r"set\(PROJECT_VERSION_MINOR \"(.*)\"\)",
|
|
||||||
content).group(1)
|
|
||||||
version_patch = re.search(r"set\(PROJECT_VERSION_PATCH \"(.*)\"\)",
|
|
||||||
content).group(1)
|
|
||||||
self.version = "%s.%s.%s" % (
|
|
||||||
version_major.strip(),
|
|
||||||
version_minor.strip(),
|
|
||||||
version_patch.strip(),
|
|
||||||
)
|
|
||||||
|
|
||||||
def requirements(self):
|
|
||||||
if self.settings.os == "Windows":
|
|
||||||
self.requires("pthreads4w/3.0.0")
|
|
||||||
if self.options.with_tests:
|
|
||||||
self.build_requires("gtest/1.15.0")
|
|
||||||
|
|
||||||
def layout(self):
|
|
||||||
cmake_layout(self)
|
|
||||||
|
|
||||||
def generate(self):
|
|
||||||
deps = CMakeDeps(self)
|
|
||||||
deps.generate()
|
|
||||||
tc = CMakeToolchain(self)
|
|
||||||
tc.variables["AUTOTEST"] = self.options.with_tests
|
|
||||||
tc.variables["BUILD_MISC_TESTS"] = self.options.with_tests
|
|
||||||
tc.variables["UNITTEST"] = self.options.with_tests
|
|
||||||
tc.variables["TEST_TIMEOUT_SECONDS"] = "300"
|
|
||||||
|
|
||||||
tc.variables["ENABLE_SHARED"] = self.options.shared
|
|
||||||
tc.variables["ENABLE_STATIC"] = not self.options.shared
|
|
||||||
|
|
||||||
tc.variables["MUST_BUILD_TOXAV"] = True
|
|
||||||
|
|
||||||
if self.settings.os == "Windows":
|
|
||||||
tc.variables["MSVC_STATIC_SODIUM"] = True
|
|
||||||
tc.variables[
|
|
||||||
"CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS"] = self.options.shared
|
|
||||||
tc.variables["FLAT_OUTPUT_STRUCTURE"] = self.options.shared
|
|
||||||
tc.generate()
|
|
||||||
|
|
||||||
def build(self):
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.configure()
|
|
||||||
cmake.build()
|
|
||||||
if self.options.with_tests:
|
|
||||||
cmake.ctest(cli_args=["--output-on-failure"])
|
|
||||||
|
|
||||||
def package(self):
|
|
||||||
cmake = CMake(self)
|
|
||||||
cmake.install()
|
|
||||||
|
|
||||||
def package_info(self):
|
|
||||||
self.cpp_info.libs = collect_libs(self)
|
|
||||||
|
|
||||||
if self.settings.os == "Windows":
|
|
||||||
self.cpp_info.system_libs = ["Ws2_32", "Iphlpapi"]
|
|
||||||
Reference in New Issue
Block a user