From 07d97c352e8a7d67a09073800dafb13e12df4e53 Mon Sep 17 00:00:00 2001 From: Alexander Vieth Date: Wed, 9 Oct 2024 15:48:53 +0200 Subject: [PATCH] Conditionaly vcpkg --- conanfile.py | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/conanfile.py b/conanfile.py index 4976ed5..9977a24 100644 --- a/conanfile.py +++ b/conanfile.py @@ -124,27 +124,28 @@ def generate(self): tc.variables["MV_UNITY_BUILD"] = "ON" # Install vcpkg dependencies - vcpkg_dir = pathlib.Path(os.environ["VCPKG_ROOT"]) - vcpkg_exe = vcpkg_dir / "vcpkg.exe" if self.settings.os == "Windows" else vcpkg_dir / "vcpkg" - vcpkg_tc = vcpkg_dir / "scripts" / "buildsystems" / "vcpkg.cmake" - - vcpkg_triplet = "x64-windows" - if self.settings.os == "Macos": - vcpkg_triplet = "x64-osx" - if self.settings.os == "Linux": - vcpkg_triplet = "x64-linux" - - print("vcpkg_dir: ", vcpkg_dir) - print("vcpkg_exe: ", vcpkg_exe) - print("vcpkg_tc: ", vcpkg_tc) - print("vcpkg_triplet: ", vcpkg_triplet) - - tc.variables["VCPKG_LIBRARY_LINKAGE"] = "dynamic" - tc.variables["VCPKG_TARGET_TRIPLET"] = vcpkg_triplet - tc.variables["VCPKG_HOST_TRIPLET"] = vcpkg_triplet - tc.variables["VCPKG_ROOT"] = vcpkg_dir.as_posix() - - tc.variables["CMAKE_PROJECT_INCLUDE"] = vcpkg_tc.as_posix() + if os.environ.get("VCPKG_ROOT", None): + vcpkg_dir = pathlib.Path(os.environ["VCPKG_ROOT"]) + vcpkg_exe = vcpkg_dir / "vcpkg.exe" if self.settings.os == "Windows" else vcpkg_dir / "vcpkg" + vcpkg_tc = vcpkg_dir / "scripts" / "buildsystems" / "vcpkg.cmake" + + vcpkg_triplet = "x64-windows" + if self.settings.os == "Macos": + vcpkg_triplet = "x64-osx" + if self.settings.os == "Linux": + vcpkg_triplet = "x64-linux" + + print("vcpkg_dir: ", vcpkg_dir) + print("vcpkg_exe: ", vcpkg_exe) + print("vcpkg_tc: ", vcpkg_tc) + print("vcpkg_triplet: ", vcpkg_triplet) + + tc.variables["VCPKG_LIBRARY_LINKAGE"] = "dynamic" + tc.variables["VCPKG_TARGET_TRIPLET"] = vcpkg_triplet + tc.variables["VCPKG_HOST_TRIPLET"] = vcpkg_triplet + tc.variables["VCPKG_ROOT"] = vcpkg_dir.as_posix() + + tc.variables["CMAKE_PROJECT_INCLUDE"] = vcpkg_tc.as_posix() tc.generate()