-
Notifications
You must be signed in to change notification settings - Fork 0
/
conanfile.py
77 lines (63 loc) · 2.86 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
import os
from conan import ConanFile
from conan.tools.files import copy
from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps
# you may need the option:
# -c tools.system.package_manager:mode=install
# -c tools.system.package_manager:sudo=True
# Options can be passed with the command line with the following syntax:
# -o nnf/*:shared=True -o nnf/*:with_tests=False -o nnf/*:with_gui=True
class NexusNodeFramework(ConanFile):
name = "nnf"
version = "0.1"
# Binary configuration
settings = "os", "compiler", "build_type"
options = {"shared": [True, False], "with_tests": [True, False], "with_gui": [True, False]}
default_options = {"shared": False, "with_tests": True, "with_gui": True}
def requirements(self):
self.requires("boost/[~1]")
if self.options.with_gui:
self.requires("imgui/[~1]")
self.requires("glad/[~0]")
self.requires("glfw/[~3]")
if self.options.with_tests:
self.requires("gtest/[~1]")
def build_requirements(self):
self.tool_requires("cmake/[~3]")
self.tool_requires("ninja/[~1]")
def layout(self):
cmake_layout(self)
# configure the output of the conan files to '.conan' in linux
# in windows will be in 'build'
multi = True if self.settings.get_safe("compiler") == "msvc" else False
if multi:
self.folders.generators = os.path.join("build", "generators")
self.folders.build = "build"
else:
self.folders.generators = os.path.join(".conan", str(self.settings.build_type), "generators")
self.folders.build = os.path.join(".conan", str(self.settings.build_type))
def generate(self):
# imports the backend render from imgui into the folder bindings
if self.options.with_gui:
copy(self, "*glfw*", os.path.join(self.dependencies["imgui"].package_folder,
"res", "bindings"), os.path.join(self.source_folder, "lib/GUI/bindings"))
copy(self, "*opengl3*", os.path.join(self.dependencies["imgui"].package_folder,
"res", "bindings"), os.path.join(self.source_folder, "lib/GUI/bindings"))
# Generates the project files from cmake
deps = CMakeDeps(self)
deps.generate()
tc = CMakeToolchain(self,
generator="Ninja")
tc.variables["CMAKE_EXPORT_COMPILE_COMMANDS"] = "ON"
tc.variables["CMAKE_BUILD_TYPE"] = self.settings.build_type
# pass the option BUILD_GUI to the cmake
tc.variables["BUILD_GUI"] = self.options.with_gui
tc.variables["ENABLE_TESTING"] = self.options.with_tests
tc.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
cmake = CMake(self)
cmake.install()