Skip to content

Major changes of installation in CMake project files - #433

Merged
penggrin12 merged 3 commits into
RobLoach:masterfrom
stalker57241:master
Sep 25, 2026
Merged

penggrin12 merged 3 commits into
RobLoach:masterfrom
stalker57241:master

Conversation

@stalker57241

Copy link
Copy Markdown
Contributor

Added versioning and made project linkable in interface mode. Before it, I don't like, how bad it linked at example:
Here told, that it tries to link raylib-cpp with target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib_cpp), and it's don't works. Example is for v6.0.0, and it doesn't compiles properly. Standalone it compiles normally, but when I tried to disable fetching of github to use locally installed raylib-cpp, it doesn't work. CMake doesn't know, what is raylib_cpp. Now I let it know.

P. S. And fixed a web configurations of CMakeLists.txt from that example.

Now you can just:
```cmake
target_link_libraries(
    ${PROJECT_NAME} INTERFACE raylib_cpp::raylib_cpp
)
```
Fixed Web configurations example
@penggrin12
penggrin12 merged commit 161665c into RobLoach:master Sep 25, 2026
13 checks passed
@penggrin12

Copy link
Copy Markdown
Collaborator

Tests seem to build both in our workflows and on my machine. Спасибо!

@stalker57241

Copy link
Copy Markdown
Contributor Author

Literally, before this pr sudo cmake --install . for raylib-cpp is not registered it in system, so, when somebody tried find_package(raylib_cpp), flag raylib_cpp_FOUND is set to NO ALWAYS, and he can't compile project properly. Yeah, he can just include it, but he can't be sure, that it is really installed. And can't be sure, that FerchContent installs it.

add_executable(${PROJECT_NAME} ${SOURCES})
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11)
target_link_libraries(${PROJECT_NAME} PUBLIC raylib raylib_cpp)
target_link_libraries(${PROJECT_NAME} PUBLIC raylib INTERFACE raylib_cpp)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raylib_cpp is INTERFACE library, so it CANNOT be linked like PUBLIC library.

@stalker57241 stalker57241 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raylib_cpp is INTERFACE library, so it CANNOT be linked like PUBLIC library.

@RobLoach

Copy link
Copy Markdown
Owner

I thought linking the interface added the include path and such?

@stalker57241

Copy link
Copy Markdown
Contributor Author

I thought linking the interface added the include path and such?

Yeah, it adds the include path, and such. But when it's all, that library got, we need to specify it for cmake. There is wasn't.

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

Successfully merging this pull request may close these issues.

3 participants