From adc56584f7c69d88038b68a7501a59dcf5a482f5 Mon Sep 17 00:00:00 2001 From: Andrey Filipenkov Date: Fri, 8 Aug 2025 22:02:20 +0300 Subject: [PATCH] add vcmi-dependencies as submodule --- .gitmodules | 3 +++ conanfile.py | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++ dependencies | 1 + 3 files changed, 58 insertions(+) create mode 100644 conanfile.py create mode 160000 dependencies diff --git a/.gitmodules b/.gitmodules index d6b206fe1..57ce2608d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,3 +10,6 @@ path = launcher/lib/innoextract url = https://github.com/vcmi/innoextract.git branch = vcmi +[submodule "dependencies"] + path = dependencies + url = https://github.com/vcmi/vcmi-dependencies.git diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 000000000..b4db173f3 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,54 @@ +from dependencies.conanfile import VCMI + +from conan.tools.cmake import CMakeToolchain +from conan.tools.files import save + +from glob import glob +import os + +class VCMIApp(VCMI): + generators = "CMakeDeps" + + def _pathForCmake(self, path: str) -> str: + # CMake doesn't like \ in strings + return path.replace(os.path.sep, os.path.altsep) if os.path.altsep else path + + def _generateRuntimeLibsFile(self) -> str: + # create file with list of libs to copy to the package for distribution + runtimeLibsFile = self._pathForCmake(os.path.join(self.build_folder, "_runtime_libs.txt")) + + runtimeLibExtension = { + "Android": "so", + "iOS": "dylib", + "Macos": "dylib", + "Windows": "dll", + }.get(str(self.settings.os)) + + runtimeLibs = [] + for _, dep in self.dependencies.host.items(): + # Qt libs are copied using *deployqt + if dep.ref.name == "qt": + continue + + runtimeLibDir = '' + if self.settings.os == "Windows": + if len(dep.cpp_info.bindirs) > 0: + runtimeLibDir = dep.cpp_info.bindir + elif len(dep.cpp_info.libdirs) > 0: + runtimeLibDir = dep.cpp_info.libdir + if len(runtimeLibDir) > 0: + runtimeLibs += map(self._pathForCmake, glob(os.path.join(runtimeLibDir, f"*.{runtimeLibExtension}"))) + save(self, runtimeLibsFile, "\n".join(runtimeLibs)) + + return runtimeLibsFile + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["USING_CONAN"] = True + tc.variables["CONAN_RUNTIME_LIBS_FILE"] = self._generateRuntimeLibsFile() + if self.settings.os == "Android": + tc.variables["CMAKE_ANDROID_API"] = str(self.settings.os.api_level) + tc.variables["SDL_JAVA_SRC_DIR"] = os.path.join(self.dependencies.host["sdl"].package_folder, "share", "java", "SDL2") + elif self.settings.os == "Windows": + tc.variables["CONAN_RUNENV_SCRIPT"] = self._pathForCmake(os.path.join(self.build_folder, "conanrun.bat")) + tc.generate() diff --git a/dependencies b/dependencies new file mode 160000 index 000000000..b6f03bd54 --- /dev/null +++ b/dependencies @@ -0,0 +1 @@ +Subproject commit b6f03bd541f19ad441ffb930a2cbd000222a50bf