Hi all,
I’m working on a cross-platform SDL2 project that I want to be able to compile for PC, Mac, Linux, Browser (Emscripten), iOS, and Android.
A few months back, I got it all to work by setting up the build directories and projects manually (and verrry carefully). You can see my extremely hacky setup to get it working here: https://github.com/lwb4/tadpole
Now, I want to redo the build system so it all works with cmake. My approach is to include full source for all dependencies as git submodules, and since most of them are cmake projects, I can just add_subdirectory to tie it all together.
Well, not really. There’s one small hitch: SDL_ttf and SDL_image won’t build. SDL2 and SDL_mixer appear to be working however.
This is roughly what my top-level CMakeLists.txt file looks like:
add_subdirectory("${SDL2_DIR}")
add_subdirectory("${SDL_MIXER_DIR}")
add_subdirectory("${SDL_IMAGE_DIR}")
add_subdirectory("${SDL_TTF_DIR}")
...
target_include_directories(... "${SDL2_DIR}/include")
target_include_directories(... "${SDL2_DIR}/include" "${SDL_TTF_DIR}" "${SDL_IMAGE_DIR}" "${SDL_MIXER_DIR}/include")
target_link_libraries(Tadpole SDL2)
target_link_libraries(Tadpole SDL_mixer)
target_link_libraries(Tadpole SDL_ttf)
target_link_libraries(Tadpole SDL_image)
And here’s the error when I mkdir build && cd build && cmake ..
:
CMake Error at deps/SDL2/SDL2Config.cmake:1 (include):
include could not find load file:
/Users/lincolnbergeson/Pollywog/tadpole/deps/SDL2/SDL2Targets.cmake
Call Stack (most recent call first):
deps/SDL_image/CMakeLists.txt:7 (find_package)
-- Symbol prefix:
CMake Error at deps/SDL2/SDL2Config.cmake:1 (include):
include could not find load file:
/Users/lincolnbergeson/Pollywog/tadpole/deps/SDL2/SDL2Targets.cmake
Call Stack (most recent call first):
deps/SDL_ttf/CMakeLists.txt:47 (find_package)
The error happens when those subdirs try to find_package(SDL2 REQUIRED)
, but I don’t understand enough about how the projects are set up to know how to debug this further.
Has anyone here done something like this before? What more do I need to do to get SDL_image and SDL_ttf building?