option(NNG_SETSTACKSIZE "Use rlimit for thread stack size" ON)
set(NNG_TESTS OFF)
set(NNG_ENABLE_NNGCAT OFF)
add_subdirectory(nng)

if (NOT SDL2_FOUND)
    add_subdirectory(SDL)
else()
    message("-- Using system-installed SDL version ${SDL2_VERSION}")
endif()

add_library(imgui OBJECT
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_demo.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_draw.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_tables.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/imgui_widgets.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_sdl.cpp
    ${CMAKE_CURRENT_SOURCE_DIR}/imgui/backends/imgui_impl_sdlrenderer.cpp
)

target_include_directories(imgui PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/imgui)

find_file(XLIB_HEADER Xlib.h PATH_SUFFIXES X11)
if (XLIB_HEADER)
    message(">> XLIB_HEADER found: ${XLIB_HEADER}")
    get_filename_component(XLIB_INCLUDE_DIR ${XLIB_HEADER} DIRECTORY)
    target_include_directories(imgui SYSTEM PUBLIC ${XLIB_INCLUDE_DIR}/../)
endif()

target_link_libraries(imgui PUBLIC SDL2::SDL2)

add_subdirectory(sdl_nyan)
