This commit is contained in:
+171
@@ -0,0 +1,171 @@
|
||||
import os
|
||||
import pathlib
|
||||
|
||||
import conan
|
||||
import conan.tools.build
|
||||
import conan.tools.cmake
|
||||
import conan.tools.files
|
||||
|
||||
import modulus.config
|
||||
|
||||
config = modulus.config
|
||||
|
||||
class modulus_recipe(conan.ConanFile):
|
||||
name = "modulus"
|
||||
version = "latest"
|
||||
description = "Shared Conan/CMake tooling and C++23 utility framework"
|
||||
license = "MIT"
|
||||
package_type = "library"
|
||||
settings = "os", "arch", "compiler", "build_type"
|
||||
options = {
|
||||
"shared": [
|
||||
True,
|
||||
False,
|
||||
],
|
||||
"fPIC": [
|
||||
True,
|
||||
False,
|
||||
],
|
||||
"with_tests": [
|
||||
True,
|
||||
False,
|
||||
],
|
||||
}
|
||||
default_options = {
|
||||
"shared": False,
|
||||
"fPIC": True,
|
||||
"with_tests": False,
|
||||
"raylib/*:camera_system": False,
|
||||
"raylib/*:custom_frame_control": True,
|
||||
"raylib/*:customize_build": True,
|
||||
"raylib/*:gestures_system": True,
|
||||
"raylib/*:module_raudio": False,
|
||||
"raylib/*:opengl_version": "ES-2.0",
|
||||
"raylib/*:rprand_generator": False,
|
||||
"glfw/*:with_wayland": False,
|
||||
"glfw/*:with_x11": False,
|
||||
}
|
||||
exports = "modulus/*.py", "modulus.json"
|
||||
exports_sources = (
|
||||
"CMakeLists.txt",
|
||||
"cmake/*.cmake",
|
||||
"cmake/*.in",
|
||||
"include/*.hpp",
|
||||
"include/modulus/*.hpp",
|
||||
"src/*.cpp",
|
||||
"tests/CMakeLists.txt",
|
||||
"tests/*.cpp",
|
||||
"tests/*.hpp",
|
||||
"schemas/*.json",
|
||||
"tools/*.py",
|
||||
"tools/conan/profiles/*",
|
||||
"tools/docker/*",
|
||||
"tools/editor/*",
|
||||
"README.md",
|
||||
)
|
||||
|
||||
def config_options(self):
|
||||
settings = self.settings
|
||||
options = self.options
|
||||
if settings.os == "Windows":
|
||||
del options.fPIC
|
||||
|
||||
def configure(self):
|
||||
options = self.options
|
||||
if options.shared:
|
||||
del options.fPIC
|
||||
|
||||
def requirements(self):
|
||||
config = modulus.config.load_recipe_config(self)
|
||||
self.requires(
|
||||
modulus.config.boost_ref(config),
|
||||
transitive_headers=True,
|
||||
transitive_libs=True,
|
||||
options=modulus.config.boost_requirement_options(config),
|
||||
)
|
||||
self.requires(
|
||||
"openssl/4.0.1",
|
||||
transitive_headers=True,
|
||||
transitive_libs=True,
|
||||
)
|
||||
self.requires(
|
||||
"sqlite3/3.53.2",
|
||||
transitive_headers=True,
|
||||
transitive_libs=True,
|
||||
)
|
||||
self.requires(
|
||||
"raylib/6.0",
|
||||
transitive_headers=True,
|
||||
transitive_libs=True,
|
||||
)
|
||||
self.requires(
|
||||
"miniaudio/0.11.22",
|
||||
transitive_headers=True,
|
||||
transitive_libs=True,
|
||||
)
|
||||
|
||||
def generate(self):
|
||||
options = self.options
|
||||
deps = conan.tools.cmake.CMakeDeps(self)
|
||||
deps.generate()
|
||||
toolchain = conan.tools.cmake.CMakeToolchain(self)
|
||||
if hasattr(toolchain, "user_presets_path"):
|
||||
toolchain.user_presets_path = False
|
||||
toolchain.variables["BUILD_SHARED_LIBS"] = bool(options.shared)
|
||||
toolchain.variables["BUILD_TESTING"] = bool(options.with_tests)
|
||||
toolchain.generate()
|
||||
|
||||
def build(self):
|
||||
options = self.options
|
||||
cmake = conan.tools.cmake.CMake(self)
|
||||
cmake.configure()
|
||||
cmake.build()
|
||||
if options.with_tests and conan.tools.build.can_run(self):
|
||||
cmake.test(target="check")
|
||||
|
||||
def package_id(self):
|
||||
self.info.options.rm_safe("with_tests")
|
||||
|
||||
def package(self):
|
||||
cmake = conan.tools.cmake.CMake(self)
|
||||
cmake.install()
|
||||
package = pathlib.Path(self.package_folder)
|
||||
conan.tools.files.copy(self, "*.py", src=pathlib.Path(self.recipe_folder) / "modulus", dst=package / "modulus", keep_path=True)
|
||||
conan.tools.files.copy(self, "*", src=pathlib.Path(self.source_folder) / "tools", dst=package / "tools", keep_path=True)
|
||||
|
||||
def package_info(self):
|
||||
cpp_info = self.cpp_info
|
||||
cpp_info.set_property("cmake_file_name", "modulus")
|
||||
cpp_info.set_property("cmake_target_name", "modulus::all")
|
||||
cpp_info.set_property(
|
||||
"cmake_build_modules",
|
||||
[os.path.join("lib", "cmake", "modulus", "modulus_third_party.cmake")],
|
||||
)
|
||||
components = cpp_info.components
|
||||
components["modulus"].set_property("cmake_target_name", "modulus::modulus")
|
||||
components["modulus"].libs = ["modulus"]
|
||||
components["modulus"].requires = ["boost::json"]
|
||||
|
||||
components["boost_json"].set_property("cmake_target_name", "modulus::boost_json")
|
||||
components["boost_json"].requires = ["boost::json"]
|
||||
|
||||
components["openssl"].set_property("cmake_target_name", "modulus::openssl")
|
||||
components["openssl"].requires = ["openssl::ssl", "openssl::crypto"]
|
||||
|
||||
components["sqlite"].set_property("cmake_target_name", "modulus::sqlite")
|
||||
components["sqlite"].requires = ["sqlite3::sqlite"]
|
||||
|
||||
components["raylib"].set_property("cmake_target_name", "modulus::raylib")
|
||||
components["raylib"].requires = ["raylib::raylib"]
|
||||
if self.settings.os == "Linux":
|
||||
components["raylib"].system_libs = [
|
||||
"EGL",
|
||||
"GLESv2",
|
||||
"drm",
|
||||
"gbm",
|
||||
"atomic",
|
||||
"dl",
|
||||
]
|
||||
|
||||
components["miniaudio"].set_property("cmake_target_name", "modulus::miniaudio")
|
||||
components["miniaudio"].requires = ["miniaudio::miniaudio"]
|
||||
Reference in New Issue
Block a user