Reputation: 85
I have the following conditions:
add_subdirectory
Problem here is that SDL2_image is trying to find SDL2 with find_package
, but as i mentioned i am building SDL2 alongside with my project, so find_package
fails to find it in the system. After that i am setting SDL2_DIR pointing to the correct directory, but SDL2Config.cmake inside one of the most popular unofficial repos are just including invalid file and thus breaks all project.
Question is. How i can nicely solve this issue? I have all my deps built from sources alongside the project and it works nice. Of course i can build SDL2_image and include binaries separately, but this is not a nice solution in my opinion.
Upvotes: 3
Views: 393
Reputation: 31020
Create a FindSDL2.cmake
with the following:
add_library(SDL2::SDL2 ALIAS SDL2)
Make sure find_package
sees this file first by adding the path to it to CMAKE_MODULE_PATH
or CMAKE_PREFIX_PATH
.
Upvotes: 1