texus / TGUI

Cross-platform modern c++ GUI
https://tgui.eu
zlib License
831 stars 95 forks source link

How to use SDL2/3 backend with cmake `FetchContent` #231

Closed TakWolf closed 11 months ago

TakWolf commented 11 months ago
FetchContent_Declare(SDL2
        GIT_REPOSITORY https://github.com/libsdl-org/SDL.git
        GIT_TAG release-2.28.5
)
FetchContent_MakeAvailable(SDL2)

FetchContent_Declare(TGUI
        GIT_REPOSITORY https://github.com/texus/TGUI.git
        GIT_TAG v1.1.0
)
set(TGUI_BACKEND SDL_OPENGL3)
FetchContent_MakeAvailable(TGUI)

...

target_link_libraries(${PROJECT_NAME} PRIVATE SDL2main SDL2-static)
target_link_libraries(${PROJECT_NAME} PRIVATE tgui)
-- If something was not detected, although the libraries
-- were installed, then make sure you have set the
-- CFLAGS and LDFLAGS environment variables correctly.
-- 
-- Activating backend SDL_OPENGL3 (TGUI/Backend/SDL-OpenGL3.hpp)
-- Configuring done (0.7s)
CMake Error: install(EXPORT "TGUIConfigExport" ...) includes target "tgui" which requires target "SDL2-static" that is not in any export set.
CMake Error in cmake-build-debug/_deps/tgui-src/src/CMakeLists.txt:
  export called with target "tgui" which requires target "SDL2-static" that
  is not in any export set.

-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

For each SFML + TGUI or SDL2 only by using FetchContent all running well.

But use SDL_OPENGL3 / SDL_RENDERER will lead to the above errors.

texus commented 11 months ago

Can you try with the latest commit of the 1.x branch instead of the 1.1.0 tag? This should have been fixed already, but only recently (after the 1.1 release).

TakWolf commented 11 months ago

I changed it to the following version and it can be run. thanks!

FetchContent_Declare(TGUI
        GIT_REPOSITORY https://github.com/texus/TGUI.git
        GIT_TAG nightly_build
)