Skip to content

Commit

Permalink
fix cmake _him_check_if_no_backend_selected
Browse files Browse the repository at this point in the history
  • Loading branch information
pthom committed Dec 31, 2023
1 parent 97f7339 commit d0fb180
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions hello_imgui_cmake/hello_imgui_build_lib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,10 @@ function(him_sanity_checks)
set(HELLOIMGUI_USE_GLFW_OPENGL3 ON CACHE BOOL "" FORCE)
endif()

_him_check_if_no_backend_selected() # will set HELLOIMGUI_NO_BACKEND_SELECTED to ON if no backend selected
_him_check_if_no_backend_selected(no_backend_selected)

if (HELLOIMGUI_NO_BACKEND_SELECTED)
if (no_backend_selected)
message(FATAL_ERROR "ARGHH3")
set(backend_message "
HelloImGui: no backend selected!
In order to select your own backend, use one of the cmake options below:
Expand All @@ -120,15 +121,16 @@ function(him_sanity_checks)
")
message(STATUS "${backend_message}")

_him_try_select_glfw_opengl3_if_no_backend_selected() # may change HELLOIMGUI_NO_BACKEND_SELECTED to OFF
_him_try_select_glfw_opengl3_if_no_backend_selected()
endif()

if (HELLOIMGUI_NO_BACKEND_SELECTED)
_him_check_if_no_backend_selected(no_backend_selected)
if (no_backend_selected)
message(FATAL_ERROR "HelloImGui: no backend selected, and could not auto-select one!")
endif()
endfunction()

function(_him_check_if_no_backend_selected) # will set HELLOIMGUI_NO_BACKEND_SELECTED to ON if no backend selected
function(_him_check_if_no_backend_selected out_result) # will set out_result to ON if no backend selected
if (NOT HELLOIMGUI_USE_SDL_OPENGL3
AND NOT HELLOIMGUI_USE_GLFW_OPENGL3
AND NOT HELLOIMGUI_USE_SDL_METAL
Expand All @@ -138,7 +140,9 @@ function(_him_check_if_no_backend_selected) # will set HELLOIMGUI_NO_BACKEND_SEL
AND NOT HELLOIMGUI_USE_SDL_DIRECTX11
AND NOT HELLOIMGUI_USE_SDL_DIRECTX12
)
set(HELLOIMGUI_NO_BACKEND_SELECTED ON CACHE INTERNAL "")
set(${out_result} ON PARENT_SCOPE)
else()
set(${out_result} OFF PARENT_SCOPE)
endif()
endfunction()

Expand Down Expand Up @@ -171,7 +175,6 @@ function(_him_try_select_glfw_opengl3_if_no_backend_selected)
if (HELLOIMGUI_DOWNLOAD_GLFW_IF_NEEDED)
set(HELLOIMGUI_USE_GLFW_OPENGL3 ON CACHE BOOL "" FORCE)
message(STATUS "HelloImGui: using HELLOIMGUI_USE_GLFW_OPENGL3 as default default backend")
set(HELLOIMGUI_NO_BACKEND_SELECTED OFF CACHE INTERNAL "")
else()
# Check if Glfw can be found
find_package(glfw3 QUIET)
Expand All @@ -180,7 +183,6 @@ function(_him_try_select_glfw_opengl3_if_no_backend_selected)
message(STATUS
"HelloImGui: using HELLOIMGUI_USE_GLFW_OPENGL3 as default default backend (glfw was found via find_package(glfw3))
")
set(HELLOIMGUI_NO_BACKEND_SELECTED OFF CACHE INTERNAL "")
else()
set(glfw_help_msg "
you can install glfw via your package manager (apt, pacman, etc).
Expand Down

0 comments on commit d0fb180

Please sign in to comment.