bootstrap-toolchain/packages/cmake/conanfile.py

72 lines
2.0 KiB
Python

# Toolchain builder for the Serene programming language
#
# Copyright (c) 2019-2023 Sameer Rahmani <lxsameer@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
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, with_musl_toolchain
class Cmake(ConanFile):
name = "cmake"
version = get_version("cmake")
settings = "os", "arch", "build_type"
options = {
"libc": ["glibc", "musl"],
}
default_options = {"libc": "glibc"}
def source(self):
get(
self,
f"https://github.com/Kitware/CMake/archive/v{self.version}.tar.gz",
)
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": "ON",
"OPENSSL_USE_STATIC_LIBS": "ON",
"BUILD_TESTING": "OFF",
}
)
cmake.configure(
flags,
build_script_folder=f"CMake-{self.version}",
)
cmake.build()
cmake.install()
def package_info(self):
self.buildenv_info.prepend_path(
"PATH", os.path.join(self.package_folder, "bin")
)