Fix the toolchain config in cmake and ninja

This commit is contained in:
Sameer Rahmani 2023-04-23 10:33:25 +01:00
parent 951e385547
commit 7362583790
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
2 changed files with 37 additions and 11 deletions

View File

@ -19,13 +19,18 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get
from conf.utils import with_static_flags, get_version
from conf.utils import with_static_flags, get_version, with_musl_toolchain
class Cmake(ConanFile):
name = "cmake"
version = get_version("cmake")
settings = "os", "arch", "build_type", "compiler"
settings = "os", "arch", "build_type"
options = {
"libc": ["glibc", "musl"],
}
default_options = {"libc": "glibc"}
def source(self):
get(
@ -35,19 +40,25 @@ class Cmake(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
if self.options.libc == "musl":
with_musl_toolchain(self, tc)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
flags = with_static_flags(
{
"CMAKE_USE_OPENSSL": "OFF",
"BUILD_TESTING": "OFF",
}
)
cmake.configure(
with_static_flags(
{
"CMAKE_USE_OPENSSL": "OFF",
"BUILD_TESTING": "OFF",
}
),
flags,
build_script_folder=f"CMake-{self.version}",
)
cmake.build()

View File

@ -19,17 +19,27 @@ from conan import ConanFile
from conan.tools.cmake import CMake, CMakeToolchain, CMakeDeps
from conan.tools.files import get
from conf.utils import with_static_flags, get_version
from conf.utils import with_static_flags, get_version, with_musl_toolchain
class Ninja(ConanFile):
name = "ninja"
settings = "os", "arch", "build_type", "compiler"
settings = "os", "arch", "build_type"
version = get_version("ninja")
options = {
"libc": ["glibc", "musl"],
}
default_options = {"libc": "glibc"}
def requirements(self):
self.tool_requires(f"cmake/{get_version('cmake')}@{self.user}/{self.channel}")
# if self.options.libc == "musl":
# self.requires(
# f"stage2-sysroot/{get_version('llvm')}@{self.user}/{self.channel}"
# )
def source(self):
get(
self,
@ -41,6 +51,9 @@ class Ninja(ConanFile):
def generate(self):
tc = CMakeToolchain(self)
if self.options.libc == "musl":
with_musl_toolchain(self, tc)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
@ -51,8 +64,10 @@ class Ninja(ConanFile):
def build(self):
cmake = CMake(self)
flags = with_static_flags()
cmake.configure(
with_static_flags({}),
flags,
build_script_folder=f"ninja-{self.version}",
)
cmake.build()