mirror of
https://github.com/cimgui/cimgui.git
synced 2025-08-13 13:18:31 +01:00
Merge pull request #192 from GrimMaple/master
Add SDL2 fallback in backend_test\CMakeLists.txt
This commit is contained in:
@@ -27,7 +27,7 @@ Notes:
|
|||||||
* cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location) (only if cimgui is generated with freetype option)
|
* cmake options are IMGUI_STATIC (compiling as static library), IMGUI_FREETYPE (for using Freetype2) and FREETYPE_PATH (Freetype2 cmake install location) (only if cimgui is generated with freetype option)
|
||||||
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build
|
* or as in https://github.com/sonoro1234/LuaJIT-ImGui/tree/master/build
|
||||||
|
|
||||||
For compiling with backends there is now an example with SDL2 and opengl3 in folder backend_test. It will generate a cimgui_sdl module and a test_sdl executable. You only need to provide SDL_PATH telling cmake where to look for SDL2 cmake installation.
|
For compiling with backends there is now an example with SDL2 and opengl3 in folder backend_test. It will generate a cimgui_sdl module and a test_sdl executable.
|
||||||
|
|
||||||
# using generator
|
# using generator
|
||||||
|
|
||||||
|
@@ -66,7 +66,13 @@ endif(WIN32)
|
|||||||
list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_sdl.cpp)
|
list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_sdl.cpp)
|
||||||
if(DEFINED SDL_PATH)
|
if(DEFINED SDL_PATH)
|
||||||
message(STATUS "SDL_PATH defined as " ${SDL_PATH})
|
message(STATUS "SDL_PATH defined as " ${SDL_PATH})
|
||||||
FIND_PACKAGE(SDL2 REQUIRED PATHS ${SDL_PATH})
|
FIND_PACKAGE(SDL2 PATHS ${SDL_PATH})
|
||||||
|
else(DEFINED SDL_PATH)
|
||||||
|
# If SDL_PATH is not set, fallback and attempt to find SDL cmake script at a default location
|
||||||
|
find_package(SDL2)
|
||||||
|
endif(DEFINED SDL_PATH)
|
||||||
|
|
||||||
|
if(SDL2_FOUND)
|
||||||
get_target_property(SDL_INCLUDE SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
|
get_target_property(SDL_INCLUDE SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
message(STATUS "sdlinclude is " ${SDL_INCLUDE})
|
message(STATUS "sdlinclude is " ${SDL_INCLUDE})
|
||||||
if ("${SDL_INCLUDE}" STREQUAL "" OR "${SDL_INCLUDE}" STREQUAL "SDL_INCLUDE-NOTFOUND") #if not found latest SDL2 cmake config use older
|
if ("${SDL_INCLUDE}" STREQUAL "" OR "${SDL_INCLUDE}" STREQUAL "SDL_INCLUDE-NOTFOUND") #if not found latest SDL2 cmake config use older
|
||||||
@@ -80,10 +86,13 @@ if(DEFINED SDL_PATH)
|
|||||||
set(SDL_MAIN SDL2::SDL2main)
|
set(SDL_MAIN SDL2::SDL2main)
|
||||||
message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY})
|
message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY})
|
||||||
endif()
|
endif()
|
||||||
else(DEFINED SDL_PATH)
|
else(SDL2_FOUND)
|
||||||
message(STATUS "SDL_PATH not defined")
|
if(DEFINED SDL_PATH)
|
||||||
set(IMGUI_SDL_LIBRARY SDL2)
|
message(FATAL_ERROR "Cannot find SDL at SDL_PATH")
|
||||||
endif(DEFINED SDL_PATH)
|
else(DEFINED SDL_PATH)
|
||||||
|
message(FATAL_ERROR "Cannot find SDL. Maybe try specifying SDL_PATH?")
|
||||||
|
endif(DEFINED SDL_PATH)
|
||||||
|
endif(SDL2_FOUND)
|
||||||
|
|
||||||
add_library(cimgui_sdl SHARED ${IMGUI_SOURCES})
|
add_library(cimgui_sdl SHARED ${IMGUI_SOURCES})
|
||||||
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY})
|
target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY})
|
||||||
|
Reference in New Issue
Block a user