Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] CMake: no option to install extra headers: rcamera.h, rlgl.h, raymath.h #4087

Closed
4 tasks done
Ezbob opened this issue Jun 21, 2024 · 8 comments
Closed
4 tasks done

Comments

@Ezbob
Copy link

Ezbob commented Jun 21, 2024

Hello,

I trying to set up a simple 3D first person game by including the latest release of Raylib 5.0 through the Conan dependency manager, using the 3D first person example from this repository.
As you know, the example uses the rcamera.h header to do the camera calculations, but I have trouble including that header file.

What I can read from https://github.com/raysan5/raylib/wiki/raylib-architecture , the rcamera.h header comes as a separated header modules located in the source directory of the raylib project. This is all fine if you have access to the source directory when you need to build the game, but I only have access to the header files installed by building the install target (a standard CMake target) since these are prebuilt and downloaded by the Conan dependency manger.

I have made an ticket with the Conan dependency manager (conan-io/conan-center-index#24368) and they have told me to contact you.

I have also tried doing cmake --build <build> --target install, after a configuration step where I set the CMAKE_INSTALL_TARGET variable, to check the installed headers, and the header files installed are only:

  • raylib.h
  • raymath.h
  • rlgl.h

Which seems to correspond with the public header declaration in https://github.com/raysan5/raylib/blob/ae50bfa2cc569c0f8d5bc4315d39db64005b1b08/src/CMakeLists.txt#L24.
There seems to some options to customize the build different in https://github.com/raysan5/raylib/blob/ae50bfa2cc569c0f8d5bc4315d39db64005b1b08/CMakeOptions.txt , but I have tried to enable SUPPORT_CAMERA_SYSTEM, CUSTOMIZE_BUILD and INCLUDE_EVERYTHING, to no avail; no extra headers were included in the install tree.

What is the intended way of procuring headers from the extra modules such as rcamera.h and is there some way to install these through CMake?
Would it not make sense to add rcamera.h to the list of public headers when SUPPORT_CAMERA_SYSTEM is on? Or add an extra option to do so?

Thanks for your time.


Please, before submitting a new issue verify and check:

  • I tested it on latest raylib version from master branch
  • I checked there is no similar issue already reported
  • I checked the documentation on the wiki
  • My code has no errors or misuse of raylib

Issue description

See above.

Environment

Windows 10
CMake version 3.26.4
Visual Studio 17 2022

Issue Screenshot

Code Example

Get the Raylib 5.0 source, and in the root run:

cmake -DCMAKE_INSTALL_PREFIX=install -DCUSTOMIZE_BUILD=ON -DSUPPORT_CAMERA_SYSTEM=ON -DINCLUDE_EVERYTHING=ON -S . -B build
cmake --build build
cmake --build build --target install

In a terminal of your choice. Then after the build is done the install directory should contain the include and lib directories with the installed headers and libraries, respectively, but no rcamera.h header file.

@raysan5 raysan5 changed the title [cmake] No option to install rcamera.h and other extra headers when doing a install using CMake [build] CMake: no option to install extra headers: rcamera.h, rlgl.h, raymath.h Jun 23, 2024
@raysan5
Copy link
Owner

raysan5 commented Jun 24, 2024

@Peter0x44 Please, could you take a look to this issue? Do you think those libraries should be exposed?

@Ezbob
Copy link
Author

Ezbob commented Jun 24, 2024

Hello, I can see that you have changed the title to include the rlgl.h and raymath.h headers. These headers are installed after building the install target. The headers that is missing are rcamera.h and also the rgestures.h header.

I have a PR (not posted yet) that adds these headers to the list of public headers (and thus installed) by default, and then you can use USE_* variables to disable the installation of them.
Would this be a good solution?

@Peter0x44
Copy link
Contributor

@raysan5 I don't have any opinion on that decision.

raylib/src/Makefile

Lines 807 to 811 in ec95ee8

# Copying raylib development files to $(RAYLIB_H_INSTALL_PATH).
cp --update raylib.h $(RAYLIB_H_INSTALL_PATH)/raylib.h
cp --update raymath.h $(RAYLIB_H_INSTALL_PATH)/raymath.h
cp --update rlgl.h $(RAYLIB_H_INSTALL_PATH)/rlgl.h
@echo "raylib development files installed/updated!"

The install target of the makefile currently only copies raylib.h, rlgl.h and raymath.h. CMake is not different in this regard.

@Peter0x44
Copy link
Contributor

I do see an argument for not exposing rcamera.h, as users can easily make their own camera controllers (and probably should).

@raysan5
Copy link
Owner

raysan5 commented Jun 25, 2024

@Peter0x44 thanks for letting me know, I prefer to keep the build system aligned with Makefile, in any case, users requiring the additional headers can just copy them, they don't need to be included in the build system, adding complexity and maintenance cost.

@raysan5 raysan5 closed this as completed Jun 25, 2024
@samsnori
Copy link

Why not add an option to the build system or simply copy it? I'm new to raylib and wanted to use some of the functions that rcamera.h provides. Copying is indeed an option doesn't work well when raylib is used as a dependency in another project. Instead of simply copying the header during install by default, I have to patch the CMakeLists.txt to make my build work. Nice thing about CMake is that you can easily automate building dependencies.

Maybe I don't understand but what complexity are you talking about @raysan5? We're talking about one or two headers that get installed.

@raysan5
Copy link
Owner

raysan5 commented Nov 16, 2024

@samsnori any line added to a build system increase complexity and potential failures, note that build systems could be used on multiple operating systems and copying a file could require different programs.

I prefer to avoid that. Copy the files manually if you need them.

@samsnori
Copy link

Thank you for your quick response! I might not fully grasp the complexity involved, but it seems like adding a single line to the CMakeLists.txt file would handle the file copy automatically in a cross-platform way. While I agree that every added line increases complexity, I’d argue that, compared to the automated solution I now have to implement, adding a line to a CMakeLists.txt might actually be simpler and more user-friendly for those integrating raylib.

For anyone looking to include raylib as an external dependency in their CMake build, you can follow this approach:

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9735e267..d098676d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -24,6 +24,7 @@ endif()
 set(raylib_public_headers
     raylib.h
     rlgl.h
+    rcamera.h
     raymath.h
     )

And use this as your External Project:

  ExternalProject_Add(
   raylib
   GIT_REPOSITORY https://github.com/raysan5/raylib.git
   GIT_TAG 5.0
   DOWNLOAD_EXTRACT_TIMESTAMP FALSE
   UPDATE_COMMAND ""
   PATCH_COMMAND
     git restore <SOURCE_DIR>/src/CMakeLists.txt &&
     git apply --ignore-space-change --ignore-whitespace ${CMAKE_CURRENT_LIST_DIR}/raylib.patch
   CMAKE_ARGS
   -DCMAKE_INSTALL_PREFIX=${deps_dir}
   -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
   -DBUILD_EXAMPLES=OFF
   -DENABLE_ASAN=OFF
   -DENABLE_USAN=OFF
   -DENABLE_MSAN=OFF
   -DBUILD_SHARED_LIBS=OFF
   BUILD_BYPRODUCTS ${ray_lib}
   )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants