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 without VCPKG #685

Open
std-microblock opened this issue Oct 4, 2024 · 4 comments
Open

Build without VCPKG #685

std-microblock opened this issue Oct 4, 2024 · 4 comments
Labels
build Build system and compilation discussion Meta talk and feedback

Comments

@std-microblock
Copy link
Contributor

std-microblock commented Oct 4, 2024

I personally preferred to use git submodule to manage dependencies. Here's how I get it working.

1. Manually add dependencies of RmlUi.

I'm using GL3 backend with GLFW.

image

So freetype and glfw is added.

2. Create fake OpenGL::GL target.

(If #684 is merged, this step can be skipped)

add_library(opengl INTERFACE)
add_library(OpenGL::GL ALIAS opengl)

Cheat RmlUi as there's a OpenGL::GL target.

3. Import and create aliases for GLFW and Freetype

add_subdirectory(external/glfw)
add_library(glfw::glfw ALIAS glfw)
add_subdirectory(external/freetype)
add_library(Freetype::Freetype ALIAS freetype)

4. Build and enjoy :)

The issue is for reference only. I'll also be happy if the developer can make the process easier!

Final CMakeLists:

### Dependencies for GUI
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(external/glfw)
add_library(glfw::glfw ALIAS glfw)
add_library(opengl INTERFACE)
add_library(OpenGL::GL ALIAS opengl)
add_subdirectory(external/freetype)
add_library(Freetype::Freetype ALIAS freetype)
add_subdirectory(external/RmlUi)
set(RMLUI_BACKEND GLFW_GL3)
add_subdirectory(external/RmlUi/Backends)
@mikke89 mikke89 added discussion Meta talk and feedback build Build system and compilation labels Oct 6, 2024
@mikke89
Copy link
Owner

mikke89 commented Oct 6, 2024

Thanks a lot. I'm sure this can be helpful to other users.

There are of course many different ways to include libraries in C++, and we want to support them all. It would be nice to have some examples and tests people could look at. But I think you demonstrate here nicely that it is fairly straightforward, especially now after our CMake rewrite for RmlUi 6.0, and your PR will help too :)

I do already have some private tests that tests a lot of different build setups, such as using CMake add_subdirectory like here, using an in-source build, using the library installed, and using vcpkg. I'll see if I can find the time to clean those up and add it to the repository, both as examples and tests.

@hyblocker
Copy link

I've got a more complex example with all optional dependencies in a similar manner to the above. I'll post it when I have the time to clean it up.

@std-microblock
Copy link
Contributor Author

Thanks a lot. I'm sure this can be helpful to other users.

There are of course many different ways to include libraries in C++, and we want to support them all. It would be nice to have some examples and tests people could look at. But I think you demonstrate here nicely that it is fairly straightforward, especially now after our CMake rewrite for RmlUi 6.0, and your PR will help too :)

I do already have some private tests that tests a lot of different build setups, such as using CMake add_subdirectory like here, using an in-source build, using the library installed, and using vcpkg. I'll see if I can find the time to clean those up and add it to the repository, both as examples and tests.

For other libraries that support mutable building systems, The solution to the issue is to write buildfiles for all of the building system that might be used. For example a project might use gn, cmake, bazel and makefile at the same time. They will write a CMakeLists, a bazel build file, a gn file and a makelists at the same time. We shouldnt consist on using a single building system.

If we want to only support one building system to reduce the complexity of the library, It shouldn't be the vcpkg but should be the CMake. As the most widely used c plus plus building system, many other building system provided some compatibility layers towards cmake, some even supports using cmake libraries directly, xmake for instance.

using voice input, plz ignore any grammar error :)

@mikke89
Copy link
Owner

mikke89 commented Oct 13, 2024

Oh, we definitely won't add any other build systems anytime soon, CMake is what we've got and it's pretty much the industry standard. And we don't want to maintain multiple build systems, that effort can be much better spent elsewhere. Earlier, I meant build setups as in using the installed library, vs in-source build on so on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Build system and compilation discussion Meta talk and feedback
Projects
None yet
Development

No branches or pull requests

3 participants