Skip to content

Commit

Permalink
(conan-io#24585) raylib: add some common build settings to options
Browse files Browse the repository at this point in the history
* support custom frame control

* add some more common settings

* Update recipes/raylib/all/conanfile.py

Co-authored-by: Abril Rincón Blanco <[email protected]>

* moved from patching defines to cmake options

* Update recipes/raylib/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

* reduce number of options

* reduced number of options, added on_off converter

* removed some options

* incorporated review

* add camera, gestures and rprand support

* added resdirs

* Simplify custom modules headers

Signed-off-by: Uilian Ries <[email protected]>

* Include headers from version 3.5.0

Signed-off-by: Uilian Ries <[email protected]>

* fix rprand typo

* fix linter warnings

* Update recipes/raylib/all/conanfile.py

Co-authored-by: Uilian Ries <[email protected]>

* readd patches

---------

Signed-off-by: Uilian Ries <[email protected]>
Co-authored-by: Abril Rincón Blanco <[email protected]>
Co-authored-by: Uilian Ries <[email protected]>
  • Loading branch information
3 people authored and OMGtechy committed Dec 31, 2024
1 parent 7b5e6d4 commit effafc5
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
68 changes: 68 additions & 0 deletions recipes/raylib/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,41 @@ class RaylibConan(ConanFile):
"shared": [True, False],
"fPIC": [True, False],
"opengl_version": [None, "4.3", "3.3", "2.1", "1.1", "ES-2.0"],

"customize_build": [True, False],
"module_raudio": [True, False],
"camera_system": [True, False],
"gestures_system": [True, False],
"rprand_generator": [True, False],
"events_waiting": [True, False],
"custom_frame_control": [True, False]
}
default_options = {
"shared": False,
"fPIC": True,
"opengl_version": None,

"customize_build": False,
"module_raudio": True,
"camera_system": True,
"gestures_system": True,
"rprand_generator": True,
"events_waiting": False,
"custom_frame_control": False
}

@property
def _support_custom_modules(self):
return Version(self.version) >= "4.2.0"

@property
def _support_rprand_generator(self):
return Version(self.version) >= "5.0"

@property
def _support_frame_control(self):
return Version(self.version) >= "4.6"

def export_sources(self):
export_conandata_patches(self)

Expand All @@ -37,13 +65,27 @@ def config_options(self):
del self.options.fPIC
if self.settings.os == "Android":
del self.options.opengl_version
if not self._support_custom_modules:
del self.options.module_raudio
if not self._support_rprand_generator:
del self.options.rprand_generator
if not self._support_frame_control:
del self.options.custom_frame_control

def configure(self):
if self.options.shared:
self.options.rm_safe("fPIC")
self.settings.rm_safe("compiler.cppstd")
self.settings.rm_safe("compiler.libcxx")

if not self.options.customize_build:
self.options.rm_safe("module_raudio")
del self.options.camera_system
del self.options.gestures_system
self.options.rm_safe("rprand_generator")
del self.options.events_waiting
self.options.rm_safe("custom_frame_control")

def layout(self):
cmake_layout(self, src_folder="src")

Expand All @@ -57,6 +99,7 @@ def requirements(self):
def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)


def generate(self):
tc = CMakeToolchain(self)
tc.variables["BUILD_EXAMPLES"] = False
Expand All @@ -72,8 +115,24 @@ def generate(self):
tc.variables["USE_EXTERNAL_GLFW"] = "ON"
tc.variables["OPENGL_VERSION"] = "OFF" if not self.options.opengl_version else self.options.opengl_version
tc.variables["WITH_PIC"] = self.options.get_safe("fPIC", True)

tc.variables["CUSTOMIZE_BUILD"] = self.options.customize_build
if self.options.customize_build:
if self._support_custom_modules:
tc.variables["SUPPORT_MODULE_RAUDIO"] = self.options.module_raudio
tc.variables["SUPPORT_EVENTS_WAITING"] = self.options.events_waiting
if self._support_frame_control:
tc.variables["SUPPORT_CUSTOM_FRAME_CONTROL"] = self.options.custom_frame_control

# this makes it include the headers rcamera.h, rgesture.h and rprand.h
tc.variables["SUPPORT_CAMERA_SYSTEM"] = self.options.camera_system
tc.variables["SUPPORT_GESTURES_SYSTEM"] = self.options.gestures_system
if self._support_rprand_generator:
tc.variables["SUPPORT_RPRAND_GENERATOR"] = self.options.rprand_generator

# Due to a specific logic of cmakedeps_macros.cmake used by CMakeDeps to try to locate shared libs on Windows
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0054"] = "NEW"
tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0091"] = "NEW"
tc.generate()
deps = CMakeDeps(self)
deps.generate()
Expand All @@ -97,6 +156,15 @@ def package(self):
{"raylib": "raylib::raylib"}
)

# INFO: Custom modules are enabled by default but need to copy the headers manually
include_path = os.path.join(self.package_folder, "include")
if self.options.get_safe("camera_system", True):
copy(self, pattern="*camera.h", dst=include_path, src=os.path.join(self.source_folder, "src"))
if self.options.get_safe("gestures_system", True):
copy(self, pattern="*gestures.h", dst=include_path, src=os.path.join(self.source_folder, "src"))
if self._support_rprand_generator and self.options.get_safe("rprand_generator", True):
copy(self, pattern="rprand.h", dst=include_path, src=os.path.join(self.source_folder, "src", "external"))

def _create_cmake_module_alias_targets(self, module_file, targets):
content = ""
for alias, aliased in targets.items():
Expand Down
1 change: 1 addition & 0 deletions recipes/raylib/all/test_package/test_package.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ int main(void) {
if (CheckCollisionSpheres(center, r, center, r)) {
printf("unit sphere collides with itself!\n");
}

return 0;
}

0 comments on commit effafc5

Please sign in to comment.