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] Incorrect CMake config causes example to fail to compile #606

Closed
ethan-tqa opened this issue Jul 27, 2018 · 6 comments
Closed

[build] Incorrect CMake config causes example to fail to compile #606

ethan-tqa opened this issue Jul 27, 2018 · 6 comments

Comments

@ethan-tqa
Copy link
Contributor

Tested with MSVC 2017 internal CMake support, all examples would fail to compile due to them being unable to locate raylib.h. This one additional line will fix the problem:
include_directories("../release/include")
when added to examples/CMakeLists.txt

@a3f
Copy link
Contributor

a3f commented Jul 27, 2018

Could you submit a PR?

@ethan-tqa
Copy link
Contributor Author

Come to think of it, that is not neccessary the right solution. Why not just reference the header from souce folder? The problem may come when user uses standalone CMake but specify custom build output folder.

@a3f
Copy link
Contributor

a3f commented Jul 28, 2018

The problem may come when user uses standalone CMake but specify custom build output folder.

Ye, that the build directory is hardcoded is unfortunate. #471 could fix that (and this issue as well)...

@raysan5 raysan5 changed the title Incorrect CMake config causes example to fail to compile [build] Incorrect CMake config causes example to fail to compile Jul 28, 2018
a3f added a commit to a3f/raylib that referenced this issue Jul 29, 2018
Remove that link_libraries_to_executable() hack and defines a proper
raylib target that can be used with target_link_libraries.

The same target is also available for external (user) code by using
find_package(raylib).

This results in:

- Remove hardcoded build directories from examples and games CMakeLists.txt
- Allow rlgl_standalone and other special examples to be built easily
- Allow CMake projects to find_package(raylib instead of fiddling with pkg-config
- Makes code a little more maintainable
- Fixes raysan5#471, raysan5#606.
- Makes code less confusing by removing the double use of PLATFORM (raysan5#584).

Note that this is still not _The Right Way_(TM), because normally
raylib-config.cmake (or its includes) would be automatically generated.
I didn't manage to get that to work though, so I went the easier route
of just wrapping pkg_check_modules for consumption by find_package.
@a3f
Copy link
Contributor

a3f commented Jul 29, 2018

I will merge #608 soon that should fix this problem by removing the hardcoded paths. Please test and report if it fixes your issue

a3f added a commit to a3f/raylib that referenced this issue Jul 29, 2018
Remove that link_libraries_to_executable() hack and defines a proper
raylib target that can be used with target_link_libraries.

The same target is also available for external (user) code by using
find_package(raylib).

This results in:

- Remove hardcoded build directories from examples and games CMakeLists.txt
- Allow rlgl_standalone and other special examples to be built easily
- Allow CMake projects to find_package(raylib instead of fiddling with pkg-config
- Makes code a little more maintainable
- Fixes raysan5#471, raysan5#606.
- Makes code less confusing by removing the double use of PLATFORM (raysan5#584).

Note that this is still not _The Right Way_(TM), because normally
raylib-config.cmake (or its includes) would be automatically generated.
I didn't manage to get that to work though, so I went the easier route
of just wrapping pkg_check_modules for consumption by find_package.
a3f added a commit to a3f/raylib that referenced this issue Jul 29, 2018
Remove that link_libraries_to_executable() hack and defines a proper
raylib target that can be used with target_link_libraries.

The same target is also available for external (user) code by using
find_package(raylib).

This results in:

- Remove hardcoded build directories from examples and games CMakeLists.txt
- Allow rlgl_standalone and other special examples to be built easily
- Allow CMake projects to find_package(raylib instead of fiddling with pkg-config
- Makes code a little more maintainable
- Fixes raysan5#471, raysan5#606.
- Makes code less confusing by removing the double use of PLATFORM (raysan5#584).

Note that this is still not _The Right Way_(TM), because normally
raylib-config.cmake (or its includes) would be automatically generated.
I didn't manage to get that to work though, so I went the easier route
of just wrapping pkg_check_modules for consumption by find_package.
a3f added a commit to a3f/raylib that referenced this issue Jul 29, 2018
Remove that link_libraries_to_executable() hack and defines a proper
raylib target that can be used with target_link_libraries.

The same target is also available for external (user) code by using
find_package(raylib).

This results in:

- Remove hardcoded build directories from examples and games CMakeLists.txt
- Allow rlgl_standalone and other special examples to be built easily
- Allow CMake projects to find_package(raylib instead of fiddling with pkg-config
- Makes code a little more maintainable
- Fixes raysan5#471, raysan5#606.
- Makes code less confusing by removing the double use of PLATFORM (raysan5#584).

Note that this is still not _The Right Way_(TM), because normally
raylib-config.cmake (or its includes) would be automatically generated.
I didn't manage to get that to work though, so I went the easier route
of just wrapping pkg_check_modules for consumption by find_package.
@ethan-tqa
Copy link
Contributor Author

Hey there, it appears to have solved the issue after I pulled the newest commit

@a3f
Copy link
Contributor

a3f commented Jul 30, 2018

:)

@a3f a3f closed this as completed Jul 30, 2018
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

2 participants