Skip to content
Snippets Groups Projects
Commit 47acdfd8 authored by Joscha Schmiedt's avatar Joscha Schmiedt
Browse files

WIP: Migrate to Conan 2 (issue #73)

parent d1e6250c
No related branches found
No related tags found
2 merge requests!61Release 0.3.0,!49Resolve "EXTERN: Adapt to Conan 2"
Pipeline #51714 failed
This commit is part of merge request !49. Comments created here will be created in the context of that merge request.
from conans import ConanFile, CMake, tools from conan import ConanFile
from conan.tools.cmake import CMake, cmake_layout, CMakeDeps, CMakeToolchain
from conan.tools.files import copy
from conan.errors import ConanInvalidConfiguration
class CaosdbConan(ConanFile): class CaosdbConan(ConanFile):
...@@ -20,48 +23,61 @@ class CaosdbConan(ConanFile): ...@@ -20,48 +23,61 @@ class CaosdbConan(ConanFile):
"fPIC": True, "fPIC": True,
"build_acm": False, "build_acm": False,
} }
generators = "cmake"
requires = [
("grpc/1.48.0"),
]
build_requires = [
("boost/1.78.0"),
("gtest/1.11.0"),
]
exports = ("*.cmake", "*CMakeLists.txt", "*.in", exports = ("*.cmake", "*CMakeLists.txt", "*.in",
"*.h", "*.proto", "*.c", "*.cpp", "*.h", "*.proto", "*.c", "*.cpp",
"*.rst", "*.md", "*.rst", "*.md",
) )
exports_sources = "src", "doc", "include", "test", "cmake", "proto" exports_sources = "src", "doc", "include", "test", "cmake", "proto"
def build_requirements(self):
self.tool_requires("protobuf/3.21.12")
self.tool_requires("cmake/[>=3.13]")
self.tool_requires("boost/1.78.0")
self.test_requires("gtest/1.11.0")
self.requires("grpc/1.48.4")
def config_options(self): def config_options(self):
if self.settings.os == "Windows": if self.settings.os == "Windows":
del self.options.fPIC self.options.rm_safe("fPIC")
self.options["boost"].without_python = True self.options["boost"].without_python = True
self.options["boost"].filesystem_version = "3" self.options["boost"].filesystem_version = "3"
# def source(self): def generate(self):
# self.run("git clone https://gitlab.indiscale.com/caosdb/src/caosdb-cpplib.git")
# self.run("cd caosdb-cpplib && git submodule update --init") tc = CMakeToolchain(self)
# This writes the "conan_toolchain.cmake"
tc.generate()
cmake = CMakeDeps(self)
cmake.generate()
copy(self, pattern="protoc*", dst="build_tools", src="bin")
copy(self, pattern="grpc_cpp_plugin*", dst="build_tools", src="bin")
def imports(self): def layout(self):
self.copy("protoc*", "build_tools", "bin") cmake_layout(self, src_folder=".")
self.copy("grpc_cpp_plugin*", "build_tools", "bin")
def build(self): def build(self):
cmake = CMake(self) cmake = CMake(self)
if self.options.build_acm: if self.options.build_acm:
cmake.definitions["BUILD_ACM"] = "On" cmake.definitions["BUILD_ACM"] = "On"
cmake.configure()
cmake.configure(source_folder="")
cmake.build() cmake.build()
def package(self): def package(self):
self.copy("*.h", dst="include", src="include") cmake = CMake(self)
self.copy("*.dll", dst="bin", keep_path=False) cmake.install()
self.copy("*.so", dst="lib", keep_path=False)
self.copy("*.dylib", dst="lib", keep_path=False) copy(self, pattern="*.h", dst="include", src="include")
self.copy("*.a", dst="lib", keep_path=False) copy(self, pattern="*.dll", dst="bin", keep_path=False)
copy(self, pattern="*.so", dst="lib", keep_path=False)
copy(self, pattern="*.dylib", dst="lib", keep_path=False)
copy(self, pattern="*.a", dst="lib", keep_path=False)
def package_info(self): def package_info(self):
self.cpp_info.libs = ["caosdb", "ccaosdb"] self.cpp_info.libs = ["caosdb", "ccaosdb"]
def validate(self):
if self.settings.os not in ("Linux", "Windows"):
raise ConanInvalidConfiguration(f"{self.settings.os} is currently not supported")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment