63 lines
3 KiB
CMake
63 lines
3 KiB
CMake
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
|
set(GLES_NORMALLY_REQUIRED_FOR_ARCHITECTURE ON)
|
|
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
|
|
set(GLES_NORMALLY_REQUIRED_FOR_ARCHITECTURE ON)
|
|
else()
|
|
set(GLES_NORMALLY_REQUIRED_FOR_ARCHITECTURE OFF)
|
|
endif()
|
|
option(USE_GLES "Enable using OpenGL ES" ${GLES_NORMALLY_REQUIRED_FOR_ARCHITECTURE})
|
|
option(GLES_VERSION "Version of OpenGL ES" 3)
|
|
set(IMGUI_SRC imgui_demo.cpp imgui_draw.cpp imgui_tables.cpp imgui_widgets.cpp imgui.cpp misc/cpp/imgui_stdlib.cpp)
|
|
set(IMGUI_BACKEND_SRC imgui_impl_sdlrenderer2.cpp imgui_impl_sdl2.cpp)
|
|
set(BACKEND_IMGUI_SRC_BASE main.cpp base85.cpp file_browser.cpp main.cpp RendererBackend.cpp theme.cpp)
|
|
foreach(SRC IN ITEMS ${IMGUI_BACKEND_SRC})
|
|
list(APPEND IMGUI_SRC backends/${SRC})
|
|
endforeach()
|
|
|
|
foreach(SRC IN ITEMS ${IMGUI_SRC})
|
|
list(APPEND BACKEND_IMGUI_SRC_BASE imgui/${SRC})
|
|
endforeach()
|
|
set(BACKEND_IMGUI_SRC )
|
|
foreach(SRC IN ITEMS ${BACKEND_IMGUI_SRC_BASE})
|
|
list(APPEND BACKEND_IMGUI_SRC ${CMAKE_CURRENT_SOURCE_DIR}/${BACKEND_IMGUI_SRC_BASE})
|
|
endforeach()
|
|
set(BACKEND_IMGUI_INC_BASE imgui imgui/backends imgui/misc/cpp IconFontCppHeaders assets imgui-filebrowser)
|
|
set(BACKEND_IMGUI_INC ${INC} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
|
|
foreach(INCDIR IN ITEMS ${BACKEND_IMGUI_INC_BASE})
|
|
set(BACKEND_IMGUI_INC ${BACKEND_IMGUI_INC} ${CMAKE_CURRENT_SOURCE_DIR}/${INCDIR})
|
|
endforeach()
|
|
if(USE_GLES)
|
|
set(GLComponents GLES${GLES_VERSION})
|
|
set(GLTarget GLES${GLES_VERSION})
|
|
else()
|
|
set(GLComponents OpenGL)
|
|
set(GLTarget GL)
|
|
endif()
|
|
find_package(OpenGL COMPONENTS ${GLComponents})
|
|
if (NOT ${OpenGL_FOUND})
|
|
if (DEFINED CMAKE_ANDROID_NDK)
|
|
if (USE_GLES)
|
|
find_path(GLES_INCLUDE_DIR GLES${GLES_VERSION}/gl${GLES_VERSION}.h HINTS ${CMAKE_ANDROID_NDK})
|
|
find_library(GLES2_LIBRARY libGLESv2.so HINTS ${GLES_INCLUDE_DIR}/../lib)
|
|
find_library(GLES3_LIBRARY libGLESv3.so HINTS ${GLES_INCLUDE_DIR}/../lib)
|
|
add_library(OpenGL::${GLTarget} INTERFACE IMPORTED)
|
|
target_include_directories(OpenGL::${GLTarget} INTERFACE ${GLES2_INCLUDE_DIR})
|
|
target_link_libraries(OpenGL::${GLTarget} INTERFACE ${GLES2_LIBRARY} ${GLES3_LIBRARY})
|
|
endif()
|
|
endif()
|
|
endif()
|
|
add_ui_backend(imgui_ui ${BACKEND_IMGUI_SRC})
|
|
if(USE_GLES)
|
|
target_compile_definitions(imgui_ui PRIVATE IMGUI_IMPL_OPENGL_ES${GLES_VERSION})
|
|
endif()
|
|
if(DEFINED EMSCRIPTEN)
|
|
target_compile_options(imgui_ui PRIVATE "-sUSE_SDL_IMAGE=2")
|
|
target_link_options(imgui_ui PUBLIC "-sMAX_WEBGL_VERSION=2" "-sMIN_WEBGL_VERSION=2" "-sFULL_ES3")
|
|
target_link_libraries(imgui_ui PRIVATE ${LIBINTL_LIBRARY})
|
|
else()
|
|
find_package(SDL2 REQUIRED)
|
|
find_package(SDL2_image REQUIRED)
|
|
target_link_libraries(imgui_ui PRIVATE OpenGL::${GLTarget} SDL2::SDL2 SDL2_image::SDL2_image ${LIBINTL_LIBRARY})
|
|
endif()
|
|
target_include_directories(imgui_ui PRIVATE ${BACKEND_IMGUI_INC} ${LIBINTL_INCDIRS})
|
|
target_compile_definitions(imgui_ui PRIVATE IMGUI_USER_CONFIG="imgui_config.h")
|