CMake normal add_library? |
CMake normal add_library? |
OKUMURA Yuki
Guest
|
It seems SDL's CMakeLists.txt is not written for add_subdirectory(). So, there is no difference with other non-cmake libraries; Build/Install SDL2 separately somewhere you want, set CMAKE_PREFIX_PATH in your CMakeLists.txt or cmake cache, then pick up some find_package module for SDL2 such as https://github.com/tcbrindle/sdl2-cmake-scripts Alternatively, there are countless "CMake-based" package managers available e.g.) https://github.com/ruslo/hunter , https://github.com/iauns/cpm ... but I've never tried them. Personally, I gave up using SDL's own CMakeLists.txt and wrote my own one to integrate/embed SDL2 into my own game executable.. List SDL source codes as: https://github.com/okuoku/grpcore0/blob/9ed5eb89fc62f3d9271d5ac88b2592195888cc28/sdl2-srcs.cmake Copy/Paste SDL_config.h from existing install: https://github.com/okuoku/grpcore0/blob/9ed5eb89fc62f3d9271d5ac88b2592195888cc28/include_sdl/emscripten/SDL_config.h Add include path: https://github.com/okuoku/grpcore0/blob/9ed5eb89fc62f3d9271d5ac88b2592195888cc28/CMakeLists.txt#L47 then add_executable(my_game ${my_srcs} ${sdl2_srcs}). It works well for Win32, UWP(Xbox), Android and Emscripten which i target. In-short: just add the sources then it should work -- except on emscripten -- because SDL_config.h already includes fairly good guesstimation about the platform so you don't have to "configure" it. Cool. I don't recommend doing this though. Unfortunately, I have plenty private patches against SDL2 to integrate several proprietary tools from GPU/OS vendors so I have to debug my own bugs introduced into SDL... SDL2's own CMakeLists.txt has some pitfalls (e.g. use of GLOB which is just plain wrong for add_library) when hacking against SDL2 itself... I guess the CMakeLists.txt was written for one-off build/install of the library. 2016-11-15 14:01 GMT+09:00 yano:
|
|||||||||||||||
|