-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
111 lines (98 loc) · 3.72 KB
/
conanfile.py
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import os
import shutil
from conans import ConanFile, CMake, tools
class LiblavaConan(ConanFile):
name = "liblava"
version = "0.7.3"
license = "MIT"
author = "Lava Block OÜ (code@liblava.dev)"
url = "https://liblava.dev"
description = "A modern and easy-to-use library for the Vulkan API"
topics = ("vulkan", "graphics", "rendering")
settings = "os", "compiler", "build_type", "arch"
# TODO shared library build
# requires changes to liblava CMakeLists.txt and settings for subrepos
options = {
"fPIC": [True, False],
"test": [True, False],
"demo": [True, False],
#"shared": [True, False]
}
default_options = {
"fPIC": True,
"test": False,
"demo": False,
#"shared": False
}
generators = "cmake"
no_copy_source=True
def _configure_cmake(self):
cmake = CMake(self)
cmake.definitions["CMAKE_POSITION_INDEPENDENT_CODE"] = "ON" if self.options.get_safe("fPIC") else "OFF"
cmake.definitions["LIBLAVA_TEST"] = "ON" if self.options.get_safe("test") else "OFF"
cmake.definitions["LIBLAVA_DEMO"] = "ON" if self.options.get_safe("demo") else "OFF"
cmake.definitions["LIBLAVA_TEMPLATE"] = "OFF"
cmake.configure()
return cmake
def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
def configure(self):
# Check if the current profile config supports C++20
tools.check_min_cppstd(self, "20")
def source(self):
git = tools.Git()
git.clone(self.url)
git.checkout(self.version)
# guarantee proper /MT /MD linkage in MSVC
project_line = "project(liblava VERSION {} LANGUAGES C CXX)".format(self.version)
tools.replace_in_file("CMakeLists.txt", project_line,
'''
{}
include(${{CMAKE_BINARY_DIR}}/conanbuildinfo.cmake)
conan_basic_setup()
'''
.format(project_line))
def build(self):
cmake = self._configure_cmake()
cmake.build()
def package(self):
cmake = self._configure_cmake()
cmake.install()
shutil.rmtree(os.path.join(self.package_folder, "lib/cmake"), ignore_errors=True)
self.copy("LICENSE", dst="licenses", src=self.source_folder)
def package_info(self):
self.cpp_info.includedirs = [
"include",
"include/liblava/ext"
]
self.cpp_info.libdirs = ["lib"]
self.cpp_info.bindirs = ["bin"]
self.cpp_info.cxxflags += [tools.cppstd_flag(self.settings)]
self.cpp_info.defines += ["SPDLOG_COMPILED_LIB"]
self.cpp_info.libs = [
# in correct linking order
"lava.engine",
"lava.app",
"lava.block",
"lava.frame",
"lava.asset",
"lava.resource",
"lava.base",
"lava.file",
"lava.util",
"lava.core",
"shaderc_combined",
"glfw3",
"physfs" if self.settings.compiler != "Visual Studio" else "physfs-static",
"spdlog"
]
# std::filesystem library
if self.settings.get_safe("compiler.libcxx") == "libstdc++11":
self.cpp_info.system_libs += ["stdc++fs"]
if self.settings.get_safe("compiler") in ["gcc", "clang"]:
thread_flag = "-pthread"
self.cpp_info.cxxflags += [thread_flag]
self.cpp_info.sharedlinkflags += [thread_flag]
self.cpp_info.exelinkflags += [thread_flag]
self.cpp_info.system_libs += ["dl"]