diff --git a/README.md b/README.md index 74bcc0a..af5b1f6 100644 --- a/README.md +++ b/README.md @@ -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) * 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 diff --git a/backend_test/CMakeLists.txt b/backend_test/CMakeLists.txt index 60a9365..defe939 100644 --- a/backend_test/CMakeLists.txt +++ b/backend_test/CMakeLists.txt @@ -66,7 +66,13 @@ endif(WIN32) list(APPEND IMGUI_SOURCES ${BAKENDS_FOLDER}imgui_impl_sdl.cpp) if(DEFINED 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) 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 @@ -80,10 +86,13 @@ if(DEFINED SDL_PATH) set(SDL_MAIN SDL2::SDL2main) message(STATUS ${SDL_MAIN} ${IMGUI_SDL_LIBRARY}) endif() -else(DEFINED SDL_PATH) - message(STATUS "SDL_PATH not defined") - set(IMGUI_SDL_LIBRARY SDL2) -endif(DEFINED SDL_PATH) +else(SDL2_FOUND) + if(DEFINED SDL_PATH) + message(FATAL_ERROR "Cannot find SDL at 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}) target_link_libraries(cimgui_sdl ${IMGUI_LIBRARIES} ${IMGUI_SDL_LIBRARY})