-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconanfile.py
More file actions
54 lines (44 loc) · 2.09 KB
/
Copy pathconanfile.py
File metadata and controls
54 lines (44 loc) · 2.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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"))
tc.generate()