mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-11 00:04:24 +00:00
[cmake] use ImGui with CMake
This commit is contained in:
parent
69d572bb10
commit
3507a793a9
41 changed files with 1506 additions and 189 deletions
106
CMakeLists.txt
Normal file
106
CMakeLists.txt
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(ImGui VERSION 1.92.0)
|
||||
|
||||
option(BUILD_EXAMPLES "Build examples" OFF)
|
||||
option(WITH_EXTRA_WARNINGS "Pass extra warnings to targets" OFF)
|
||||
option(EMSCRIPTEN_USE_FILE_SYSTEM "Include the misc/fonts/ folder as part of the build" OFF)
|
||||
|
||||
if (WITH_EXTRA_WARNINGS)
|
||||
if (MSVC)
|
||||
add_compile_options(/W4 /permissive-)
|
||||
else ()
|
||||
add_compile_options(-Wno-zero-as-null-pointer-constant -Wno-double-promotion -Wno-variadic-macros)
|
||||
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||
add_compile_options(-Wextra -Wpedantic)
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
add_compile_options(-Wshadow -Wsign-conversion)
|
||||
endif ()
|
||||
elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||
add_compile_options(-Weverything -Wno-reserved-id-macro -Wno-c++98-compat-pedantic -Wno-padded -Wno-poison-system-directories)
|
||||
elseif (MINGW)
|
||||
add_compile_options(-Wextra -Wpedantic)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
add_library(imgui STATIC)
|
||||
add_library(imgui::imgui ALIAS imgui)
|
||||
|
||||
target_sources(imgui
|
||||
PUBLIC
|
||||
FILE_SET HEADERS
|
||||
FILES
|
||||
imconfig.h
|
||||
imgui.h
|
||||
imgui_internal.h
|
||||
imstb_rectpack.h
|
||||
imstb_textedit.h
|
||||
imstb_truetype.h
|
||||
PRIVATE
|
||||
imgui.cpp
|
||||
imgui_demo.cpp
|
||||
imgui_draw.cpp
|
||||
imgui_tables.cpp
|
||||
imgui_widgets.cpp
|
||||
)
|
||||
|
||||
if (WITH_FREETYPE)
|
||||
target_sources(imgui
|
||||
PRIVATE
|
||||
misc/freetype/imgui_freetype.cpp
|
||||
)
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
target_compile_options(imgui PUBLIC "-sUSE_FREETYPE=1")
|
||||
target_link_options(imgui PUBLIC "-sUSE_FREETYPE=1")
|
||||
else ()
|
||||
find_package(freetype REQUIRED CONFIG)
|
||||
target_link_libraries(imgui PRIVATE Freetype::Freetype)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
target_compile_features(imgui PRIVATE cxx_std_11)
|
||||
if (MSVC)
|
||||
target_compile_options(imgui PRIVATE /W3)
|
||||
else ()
|
||||
target_compile_options(imgui PRIVATE -Wall -Wformat)
|
||||
endif ()
|
||||
|
||||
target_include_directories(imgui PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
install(TARGETS imgui
|
||||
EXPORT imguiTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
FILE_SET HEADERS DESTINATION include
|
||||
)
|
||||
|
||||
add_subdirectory(backends)
|
||||
|
||||
if (BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif ()
|
||||
|
||||
install(EXPORT imguiTargets
|
||||
NAMESPACE imgui::
|
||||
DESTINATION share/cmake/imgui
|
||||
)
|
||||
|
||||
include(CMakePackageConfigHelpers)
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/imguiConfigVersion.cmake"
|
||||
COMPATIBILITY SameMajorVersion
|
||||
)
|
||||
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/imguiConfigVersion.cmake"
|
||||
DESTINATION share/cmake/imgui
|
||||
)
|
||||
|
||||
configure_file(cmake/imguiConfig.cmake.in imguiConfig.cmake @ONLY)
|
||||
install(FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/imguiConfig.cmake"
|
||||
DESTINATION share/cmake/imgui
|
||||
)
|
||||
3
backends/CMakeLists.txt
Normal file
3
backends/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
include(cmake/FindPackages.cmake)
|
||||
include(cmake/ListBackends.cmake)
|
||||
include(cmake/ConfigureBackends.cmake)
|
||||
516
backends/cmake/ConfigureBackends.cmake
Normal file
516
backends/cmake/ConfigureBackends.cmake
Normal file
|
|
@ -0,0 +1,516 @@
|
|||
function (add_backend NAME HEADER_FILES CPP_FILES TARGET_LIBS)
|
||||
add_library(imgui_backend_${NAME} STATIC)
|
||||
add_library(imgui::backend_${NAME} ALIAS imgui_backend_${NAME})
|
||||
|
||||
target_sources(imgui_backend_${NAME}
|
||||
PUBLIC FILE_SET HEADERS FILES ${HEADER_FILES}
|
||||
PRIVATE ${CPP_FILES}
|
||||
)
|
||||
target_compile_features(imgui_backend_${NAME} PRIVATE cxx_std_11)
|
||||
if (MSVC)
|
||||
target_compile_options(imgui_backend_${NAME} PRIVATE /W3)
|
||||
else ()
|
||||
target_compile_options(imgui_backend_${NAME} PRIVATE -Wall -Wformat)
|
||||
endif ()
|
||||
|
||||
target_include_directories(imgui_backend_${NAME} PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries(imgui_backend_${NAME} PUBLIC imgui::imgui)
|
||||
target_link_libraries(imgui_backend_${NAME} PUBLIC ${TARGET_LIBS})
|
||||
|
||||
set_target_properties(imgui_backend_${NAME} PROPERTIES EXPORT_NAME "backend_${NAME}")
|
||||
install(TARGETS imgui_backend_${NAME}
|
||||
EXPORT imguiTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
FILE_SET HEADERS DESTINATION include
|
||||
)
|
||||
endfunction ()
|
||||
|
||||
function (add_emscripten_flags TARGET USE_RENDER_FLAG USE_FILESYSTEM)
|
||||
|
||||
target_sources(${TARGET}
|
||||
PUBLIC
|
||||
FILE_SET HEADERS
|
||||
FILES ${PROJECT_SOURCE_DIR}/backends/emscripten_mainloop_stub.h
|
||||
BASE_DIRS ${PROJECT_SOURCE_DIR}/backends
|
||||
)
|
||||
|
||||
target_compile_options(${TARGET}
|
||||
PUBLIC
|
||||
-sDISABLE_EXCEPTION_CATCHING=1
|
||||
-Os
|
||||
)
|
||||
|
||||
target_compile_options(${TARGET} PUBLIC ${USE_RENDER_FLAG})
|
||||
target_link_options(${TARGET} PUBLIC ${USE_RENDER_FLAG})
|
||||
|
||||
target_link_options(${TARGET}
|
||||
PUBLIC
|
||||
"${IMGUI_EMSCRIPTEN_GLFW3}"
|
||||
"-sWASM=1"
|
||||
"-sALLOW_MEMORY_GROWTH=1"
|
||||
"-sNO_EXIT_RUNTIME=0"
|
||||
"-sASSERTIONS=1"
|
||||
"-sDISABLE_EXCEPTION_CATCHING=1"
|
||||
)
|
||||
|
||||
if (USE_FILESYSTEM)
|
||||
target_link_options(${TARGET}
|
||||
PUBLIC
|
||||
"--no-heap-copy"
|
||||
"--preload-file"
|
||||
"${PROJECT_SOURCE_DIR}/misc/fonts@/fonts"
|
||||
)
|
||||
else ()
|
||||
target_compile_options(${TARGET}
|
||||
PUBLIC
|
||||
-DIMGUI_DISABLE_FILE_FUNCTIONS
|
||||
)
|
||||
target_link_options(${TARGET}
|
||||
PUBLIC
|
||||
"-sNO_FILESYSTEM=1"
|
||||
)
|
||||
endif ()
|
||||
endfunction()
|
||||
|
||||
if ("glfw_opengl2" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_glfw.h imgui_impl_opengl2.h)
|
||||
set(CPP_FILES imgui_impl_glfw.cpp imgui_impl_opengl2.cpp)
|
||||
set(TARGET_LIBS glfw OpenGL::GL)
|
||||
|
||||
add_backend("glfw_opengl2" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("glfw_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_glfw.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_glfw.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS glfw OpenGL::GL)
|
||||
|
||||
add_backend("glfw_opengl3" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("glfw_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(glfw3 REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_glfw.h imgui_impl_vulkan.h)
|
||||
set(CPP_FILES imgui_impl_glfw.cpp imgui_impl_vulkan.cpp)
|
||||
set(TARGET_LIBS glfw Vulkan::Vulkan)
|
||||
|
||||
add_backend("glfw_vulkan" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl2_opengl2" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl2.h imgui_impl_opengl2.h)
|
||||
set(CPP_FILES imgui_impl_sdl2.cpp imgui_impl_opengl2.cpp)
|
||||
set(TARGET_LIBS SDL2::SDL2main SDL2::SDL2 OpenGL::GL)
|
||||
|
||||
add_backend("sdl2_opengl2" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl2_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl2.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_sdl2.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS SDL2::SDL2main SDL2::SDL2 OpenGL::GL)
|
||||
|
||||
add_backend("sdl2_opengl3" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl2_sdlrenderer2" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl2.h imgui_impl_sdlrenderer2.h)
|
||||
set(CPP_FILES imgui_impl_sdl2.cpp imgui_impl_sdlrenderer2.cpp)
|
||||
set(TARGET_LIBS SDL2::SDL2main SDL2::SDL2)
|
||||
|
||||
add_backend("sdl2_sdlrenderer2" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl2_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl2.h imgui_impl_vulkan.h)
|
||||
set(CPP_FILES imgui_impl_sdl2.cpp imgui_impl_vulkan.cpp)
|
||||
set(TARGET_LIBS SDL2::SDL2main SDL2::SDL2 Vulkan::Vulkan)
|
||||
|
||||
add_backend("sdl2_vulkan" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl3_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL3 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl3.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_sdl3.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS SDL3::SDL3 OpenGL::GL)
|
||||
|
||||
add_backend("sdl3_opengl3" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl3_sdlrenderer3" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL3 REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl3.h imgui_impl_sdlrenderer3.h)
|
||||
set(CPP_FILES imgui_impl_sdl3.cpp imgui_impl_sdlrenderer3.cpp)
|
||||
set(TARGET_LIBS SDL3::SDL3)
|
||||
|
||||
add_backend("sdl3_sdlrenderer3" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl3_sdlgpu3" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL3 REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl3.h imgui_impl_sdlgpu3.h imgui_impl_sdlgpu3_shaders.h)
|
||||
set(CPP_FILES imgui_impl_sdl3.cpp imgui_impl_sdlgpu3.cpp)
|
||||
set(TARGET_LIBS SDL3::SDL3)
|
||||
|
||||
add_backend("sdl3_sdlgpu3" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("sdl3_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(SDL3 REQUIRED)
|
||||
find_package(Vulkan REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl3.h imgui_impl_vulkan.h)
|
||||
set(CPP_FILES imgui_impl_sdl3.cpp imgui_impl_vulkan.cpp)
|
||||
set(TARGET_LIBS SDL3::SDL3 Vulkan::Vulkan)
|
||||
|
||||
add_backend("sdl3_vulkan" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("glut_opengl2" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(GLUT QUIET)
|
||||
if (NOT GLUT_FOUND)
|
||||
find_package(FreeGLUT REQUIRED)
|
||||
set(TARGET_LIBS FreeGLUT::freeglut_static OpenGL::GL)
|
||||
else()
|
||||
set(TARGET_LIBS glut OpenGL)
|
||||
endif ()
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
set(HEADER_FILES imgui_impl_glut.h imgui_impl_opengl2.h)
|
||||
set(CPP_FILES imgui_impl_glut.cpp imgui_impl_opengl2.cpp)
|
||||
|
||||
add_backend("glut_opengl2" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("allegro5" IN_LIST SUPPORTED_BACKENDS)
|
||||
find_package(Allegro REQUIRED)
|
||||
|
||||
add_library(imgui_alegro STATIC)
|
||||
add_library(imgui::imgui_alegro ALIAS imgui_alegro)
|
||||
|
||||
target_sources(imgui_alegro
|
||||
PUBLIC
|
||||
FILE_SET imgui_headers TYPE HEADERS
|
||||
FILES
|
||||
${PROJECT_SOURCE_DIR}/imconfig.h
|
||||
${PROJECT_SOURCE_DIR}/imgui.h
|
||||
${PROJECT_SOURCE_DIR}/imgui_internal.h
|
||||
${PROJECT_SOURCE_DIR}/imstb_rectpack.h
|
||||
${PROJECT_SOURCE_DIR}/imstb_textedit.h
|
||||
${PROJECT_SOURCE_DIR}/imstb_truetype.h
|
||||
BASE_DIRS ${PROJECT_SOURCE_DIR}
|
||||
FILE_SET config_headers TYPE HEADERS
|
||||
FILES ${PROJECT_SOURCE_DIR}/backends/imconfig_allegro5.h
|
||||
BASE_DIRS ${PROJECT_SOURCE_DIR}/backends
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/imgui.cpp
|
||||
${PROJECT_SOURCE_DIR}/imgui_demo.cpp
|
||||
${PROJECT_SOURCE_DIR}/imgui_draw.cpp
|
||||
${PROJECT_SOURCE_DIR}/imgui_tables.cpp
|
||||
${PROJECT_SOURCE_DIR}/imgui_widgets.cpp
|
||||
)
|
||||
target_compile_features(imgui_alegro PRIVATE cxx_std_11)
|
||||
if (MSVC)
|
||||
target_compile_options(imgui_alegro PRIVATE /W3)
|
||||
else ()
|
||||
target_compile_options(imgui_alegro PRIVATE -Wall -Wformat)
|
||||
endif ()
|
||||
target_compile_definitions(imgui_alegro PUBLIC "IMGUI_USER_CONFIG=<imconfig_allegro5.h>")
|
||||
|
||||
target_include_directories(imgui_alegro PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
if (WITH_FREETYPE)
|
||||
target_sources(imgui_alegro
|
||||
PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp
|
||||
)
|
||||
|
||||
find_package(freetype REQUIRED CONFIG)
|
||||
target_link_libraries(imgui_alegro PRIVATE Freetype::Freetype)
|
||||
endif ()
|
||||
|
||||
install(TARGETS imgui_alegro
|
||||
EXPORT imguiTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
FILE_SET imgui_headers DESTINATION include
|
||||
FILE_SET config_headers DESTINATION include
|
||||
)
|
||||
|
||||
add_library(imgui_backend_allegro5 STATIC)
|
||||
add_library(imgui::backend_allegro5 ALIAS imgui_backend_allegro5)
|
||||
|
||||
target_sources(imgui_backend_allegro5
|
||||
PUBLIC
|
||||
FILE_SET imgui_backend_allegro5_headers TYPE HEADERS
|
||||
FILES ${PROJECT_SOURCE_DIR}/backends/imgui_impl_allegro5.h
|
||||
BASE_DIRS ${PROJECT_SOURCE_DIR}/backends
|
||||
PRIVATE ${PROJECT_SOURCE_DIR}/backends/imgui_impl_allegro5.cpp
|
||||
)
|
||||
target_compile_features(imgui_backend_allegro5 PRIVATE cxx_std_11)
|
||||
if (MSVC)
|
||||
target_compile_options(imgui_backend_allegro5 PRIVATE /W3)
|
||||
else ()
|
||||
target_compile_options(imgui_backend_allegro5 PRIVATE -Wall -Wformat)
|
||||
endif ()
|
||||
|
||||
target_include_directories(imgui_backend_allegro5 PUBLIC
|
||||
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/backends>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries(imgui_backend_allegro5 PUBLIC imgui::imgui_alegro)
|
||||
target_link_libraries(imgui_backend_allegro5 PUBLIC Allegro::allegro Allegro::allegro_main Allegro::allegro_primitives Allegro::allegro_color Allegro::allegro_image Allegro::allegro_font Allegro::allegro_audio Allegro::allegro_memfile Allegro::allegro_dialog)
|
||||
|
||||
set_target_properties(imgui_backend_allegro5 PROPERTIES EXPORT_NAME "backend_allegro5")
|
||||
install(TARGETS imgui_backend_allegro5
|
||||
EXPORT imguiTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
FILE_SET imgui_backend_allegro5_headers DESTINATION include
|
||||
)
|
||||
endif ()
|
||||
|
||||
if ("glfw_wgpu_emscripten" IN_LIST SUPPORTED_BACKENDS)
|
||||
|
||||
set(HEADER_FILES imgui_impl_glfw.h imgui_impl_wgpu.h)
|
||||
set(CPP_FILES imgui_impl_glfw.cpp imgui_impl_wgpu.cpp)
|
||||
set(TARGET_LIBS "")
|
||||
|
||||
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.57")
|
||||
set(USE_RENDER_FLAG "--use-port=contrib.glfw3")
|
||||
else()
|
||||
# cannot use contrib.glfw3 prior to 3.1.57
|
||||
set(USE_RENDER_FLAG -s USE_GLFW=3)
|
||||
endif()
|
||||
set(USE_RENDER_FLAG "${USE_RENDER_FLAG}" -sUSE_WEBGPU=1)
|
||||
|
||||
add_backend("glfw_wgpu_emscripten" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
add_emscripten_flags(imgui_backend_glfw_wgpu_emscripten "${USE_RENDER_FLAG}" 0)
|
||||
endif ()
|
||||
|
||||
if ("glfw_opengl3_emscripten" IN_LIST SUPPORTED_BACKENDS)
|
||||
|
||||
set(HEADER_FILES imgui_impl_glfw.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_glfw.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS "")
|
||||
|
||||
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.57")
|
||||
set(USE_RENDER_FLAG "--use-port=contrib.glfw3")
|
||||
else()
|
||||
# cannot use contrib.glfw3 prior to 3.1.57
|
||||
set(USE_RENDER_FLAG "-sUSE_GLFW=3")
|
||||
endif()
|
||||
|
||||
add_backend("glfw_opengl3_emscripten" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
add_emscripten_flags(imgui_backend_glfw_opengl3_emscripten "${USE_RENDER_FLAG}" 0)
|
||||
endif ()
|
||||
|
||||
if ("sdl2_opengl3_emscripten" IN_LIST SUPPORTED_BACKENDS)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl2.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_sdl2.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS "")
|
||||
|
||||
set(USE_RENDER_FLAG "-sUSE_SDL=2")
|
||||
|
||||
add_backend("sdl2_opengl3_emscripten" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
add_emscripten_flags(imgui_backend_sdl2_opengl3_emscripten "${USE_RENDER_FLAG}" 1)
|
||||
endif ()
|
||||
|
||||
if ("sdl3_opengl3_emscripten" IN_LIST SUPPORTED_BACKENDS)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl3.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_sdl3.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS "")
|
||||
|
||||
set(USE_RENDER_FLAG "-sUSE_SDL=3")
|
||||
|
||||
add_backend("sdl3_opengl3_emscripten" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
add_emscripten_flags(imgui_backend_sdl3_opengl3_emscripten "${USE_RENDER_FLAG}" 1)
|
||||
endif ()
|
||||
|
||||
if ("sdl3_sdlrenderer3_emscripten" IN_LIST SUPPORTED_BACKENDS)
|
||||
|
||||
set(HEADER_FILES imgui_impl_sdl3.h imgui_impl_sdlrenderer3.h)
|
||||
set(CPP_FILES imgui_impl_sdl3.cpp imgui_impl_sdlrenderer3.cpp)
|
||||
set(TARGET_LIBS "")
|
||||
|
||||
set(USE_RENDER_FLAG "-sUSE_SDL=3")
|
||||
|
||||
add_backend("sdl3_sdlrenderer3_emscripten" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
add_emscripten_flags(imgui_backend_sdl3_sdlrenderer3_emscripten "${USE_RENDER_FLAG}" 1)
|
||||
endif ()
|
||||
|
||||
if ("glfw_wgpu_dawn" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_glfw.h imgui_impl_wgpu.h)
|
||||
set(CPP_FILES imgui_impl_glfw.cpp imgui_impl_wgpu.cpp)
|
||||
set(TARGET_LIBS glfw dawn::webgpu_dawn)
|
||||
|
||||
add_backend("glfw_wgpu_dawn" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
|
||||
target_compile_features(imgui_backend_glfw_wgpu_dawn PRIVATE cxx_std_17)
|
||||
target_compile_definitions(imgui_backend_glfw_wgpu_dawn PUBLIC "IMGUI_IMPL_WEBGPU_BACKEND_DAWN")
|
||||
endif ()
|
||||
|
||||
if ("android_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_android.h imgui_impl_opengl3.h)
|
||||
set(CPP_FILES imgui_impl_android.cpp imgui_impl_opengl3.cpp)
|
||||
set(TARGET_LIBS android EGL GLESv3 log)
|
||||
|
||||
# android_opengl3 is a SHARED lib, can't use `add_backend`
|
||||
add_library(imgui_backend_android_opengl3 SHARED)
|
||||
add_library(imgui::backend_android_opengl3 ALIAS imgui_backend_android_opengl3)
|
||||
|
||||
target_link_options(imgui_backend_android_opengl3 PUBLIC "-uANativeActivity_onCreate")
|
||||
|
||||
target_compile_features(imgui_backend_android_opengl3 PRIVATE cxx_std_11)
|
||||
|
||||
# ImGui sources
|
||||
target_sources(imgui_backend_android_opengl3
|
||||
PUBLIC
|
||||
FILE_SET HEADERS FILES ${HEADER_FILES}
|
||||
PRIVATE ${CPP_FILES}
|
||||
)
|
||||
|
||||
target_compile_definitions(imgui_backend_android_opengl3 PUBLIC IMGUI_IMPL_OPENGL_ES3)
|
||||
|
||||
target_include_directories(imgui_backend_android_opengl3 PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
|
||||
target_link_libraries(imgui_backend_android_opengl3 PUBLIC imgui::imgui)
|
||||
target_link_libraries(imgui_backend_android_opengl3 PUBLIC ${TARGET_LIBS})
|
||||
|
||||
install(TARGETS imgui_backend_android_opengl3
|
||||
EXPORT imguiTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
FILE_SET HEADERS DESTINATION include
|
||||
)
|
||||
endif ()
|
||||
|
||||
if ("win32_directx9" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx9.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx9.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_9_X86_LIBRARIES})
|
||||
|
||||
add_backend("win32_directx9" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win32_directx9 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win32_directx9 PUBLIC ${IMGUI_DIRECTX_9_X86_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win32_directx10" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx10.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx10.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_10_X86_LIBRARIES})
|
||||
|
||||
add_backend("win32_directx10" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win32_directx10 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win32_directx10 PUBLIC ${IMGUI_DIRECTX_10_X86_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win32_directx11" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx11.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx11.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_11_X86_LIBRARIES})
|
||||
|
||||
add_backend("win32_directx11" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win32_directx11 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win32_directx11 PUBLIC ${IMGUI_DIRECTX_11_X86_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win32_directx12" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx12.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx12.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_12_X86_LIBRARIES})
|
||||
|
||||
add_backend("win32_directx12" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win32_directx12 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win32_directx12 PUBLIC ${IMGUI_DIRECTX_12_X86_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win64_directx9" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx9.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx9.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_9_X64_LIBRARIES})
|
||||
|
||||
add_backend("win64_directx9" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win64_directx9 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win64_directx9 PUBLIC ${IMGUI_DIRECTX_9_X64_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win64_directx10" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx10.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx10.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_10_X64_LIBRARIES})
|
||||
|
||||
add_backend("win64_directx10" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win64_directx10 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win64_directx10 PUBLIC ${IMGUI_DIRECTX_10_X64_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win64_directx11" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx11.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx11.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_11_X64_LIBRARIES})
|
||||
|
||||
add_backend("win64_directx11" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win64_directx11 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win64_directx11 PUBLIC ${IMGUI_DIRECTX_11_X64_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win64_directx12" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_dx12.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_dx12.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS ${IMGUI_DIRECTX_12_X64_LIBRARIES})
|
||||
|
||||
add_backend("win64_directx12" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
target_compile_options(imgui_backend_win64_directx12 PUBLIC /nologo /utf-8 /DUNICODE /D_UNICODE)
|
||||
target_link_directories(imgui_backend_win64_directx12 PUBLIC ${IMGUI_DIRECTX_12_X64_LIB_DIR})
|
||||
endif ()
|
||||
|
||||
if ("win32_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_opengl3.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_opengl3.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS opengl32)
|
||||
|
||||
add_backend("win32_opengl3" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
|
||||
if ("win32_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
set(HEADER_FILES imgui_impl_vulkan.h imgui_impl_win32.h)
|
||||
set(CPP_FILES imgui_impl_vulkan.cpp imgui_impl_win32.cpp)
|
||||
set(TARGET_LIBS Vulkan::Vulkan)
|
||||
|
||||
add_backend("win32_vulkan" "${HEADER_FILES}" "${CPP_FILES}" "${TARGET_LIBS}")
|
||||
endif ()
|
||||
196
backends/cmake/FindPackages.cmake
Normal file
196
backends/cmake/FindPackages.cmake
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
find_package(glfw3 QUIET)
|
||||
if (glfw3_FOUND)
|
||||
message(STATUS "Found glfw3 ${glfw3_VERSION}")
|
||||
set(HAS_IMGUI_GLFW3 ON)
|
||||
set(HAS_IMGUI_GLFW3 ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "glfw3 not found")
|
||||
endif ()
|
||||
|
||||
find_package(OpenGL QUIET)
|
||||
if (OpenGL_FOUND)
|
||||
message(STATUS "Found OpenGL")
|
||||
set(HAS_IMGUI_OPENGL ON)
|
||||
set(HAS_IMGUI_OPENGL ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "OpenGL not found")
|
||||
endif ()
|
||||
|
||||
find_package(SDL2 QUIET)
|
||||
if (SDL2_FOUND)
|
||||
message(STATUS "Found SDL2 ${SDL2_VERSION}")
|
||||
set(HAS_IMGUI_SDL2 ON)
|
||||
set(HAS_IMGUI_SDL2 ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "SDL2 not found")
|
||||
endif ()
|
||||
|
||||
find_package(SDL3 QUIET)
|
||||
if (SDL3_FOUND)
|
||||
message(STATUS "Found SDL3 ${SDL3_VERSION}")
|
||||
set(HAS_IMGUI_SDL3 ON)
|
||||
set(HAS_IMGUI_SDL3 ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "SDL3 not found")
|
||||
endif ()
|
||||
|
||||
find_package(Vulkan QUIET)
|
||||
if (Vulkan_FOUND)
|
||||
message(STATUS "Found Vulkan ${Vulkan_VERSION}")
|
||||
set(HAS_IMGUI_VULKAN ON)
|
||||
set(HAS_IMGUI_VULKAN ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "Vulkan not found")
|
||||
endif ()
|
||||
|
||||
find_package(Allegro QUIET)
|
||||
if (Allegro_FOUND)
|
||||
message(STATUS "Found Allegro ${Allegro_VERSION}")
|
||||
set(HAS_IMGUI_ALLEGRO ON)
|
||||
set(HAS_IMGUI_ALLEGRO ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "Allegro not found")
|
||||
endif ()
|
||||
|
||||
find_package(GLUT QUIET)
|
||||
if (GLUT_FOUND)
|
||||
message(STATUS "Found GLUT ${PC_GLUT_VERSION}")
|
||||
set(HAS_IMGUI_GLUT ON)
|
||||
set(HAS_IMGUI_GLUT ON PARENT_SCOPE)
|
||||
else ()
|
||||
find_package(FreeGLUT QUIET)
|
||||
if (FreeGLUT_FOUND)
|
||||
message(STATUS "Found FreeGLUT ${FreeGLUT_VERSION}")
|
||||
set(HAS_IMGUI_GLUT ON)
|
||||
set(HAS_IMGUI_GLUT ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "GLUT not found")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (EMSCRIPTEN)
|
||||
if (NOT EMSCRIPTEN_VERSION)
|
||||
message(FATAL_ERROR "EMSCRIPTEN_VERSION not found")
|
||||
endif ()
|
||||
if (EMSCRIPTEN_VERSION VERSION_LESS "3.1.43")
|
||||
message(FATAL_ERROR "ImGui requires Emscripten version >= 3.1.43, found ${EMSCRIPTEN_VERSION}")
|
||||
endif ()
|
||||
set(HAS_IMGUI_EMSCRIPTEN ON)
|
||||
set(HAS_IMGUI_EMSCRIPTEN ON PARENT_SCOPE)
|
||||
message(STATUS "Found emscripten ${EMSCRIPTEN_VERSION}")
|
||||
else ()
|
||||
message(WARNING "emscripten not found. `cmake -DCMAKE_TOOLCHAIN_FILE=emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake ...`")
|
||||
endif ()
|
||||
|
||||
find_package(Dawn QUIET)
|
||||
if (Dawn_FOUND)
|
||||
message(STATUS "Found Dawn")
|
||||
set(HAS_IMGUI_DAWN ON)
|
||||
set(HAS_IMGUI_DAWN ON PARENT_SCOPE)
|
||||
else ()
|
||||
message(WARNING "Dawn not found")
|
||||
endif ()
|
||||
|
||||
if (ANDROID_NDK)
|
||||
message(STATUS "Found ANDROID_NDK ${CMAKE_ANDROID_NDK_VERSION} at ${ANDROID_NDK}.")
|
||||
else ()
|
||||
message(WARNING "ANDROID_NDK not provided. `cmake -DCMAKE_TOOLCHAIN_FILE=android-ndk/build/cmake/android.toolchain.cmake ...`")
|
||||
endif ()
|
||||
|
||||
function (find_directx NAME INCLUDE_FILE LIBS_NAMES)
|
||||
find_path(${NAME}_INCLUDE_DIR ${INCLUDE_FILE}
|
||||
PATHS "$ENV{WindowsSdkDir}/Include/$ENV{WindowsSDKVersion}"
|
||||
PATH_SUFFIXES um
|
||||
NO_CACHE
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
if (CMAKE_GENERATOR_PLATFORM STREQUAL "win32")
|
||||
find_library(${NAME}_X86_LIBRARY ${LIBS_NAMES}
|
||||
PATHS "$ENV{WindowsSdkDir}/Lib/$ENV{WindowsSDKVersion}"
|
||||
PATH_SUFFIXES um/x86
|
||||
NO_CACHE
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
if (NOT ${${NAME}_INCLUDE_DIR} STREQUAL "" AND NOT ${${NAME}_X86_LIBRARY} STREQUAL "")
|
||||
set(HAS_IMGUI_${NAME}_X86 ON)
|
||||
set(HAS_IMGUI_${NAME}_X86 ON PARENT_SCOPE)
|
||||
set(IMGUI_${NAME}_X86_INCLUDE_DIR ${${NAME}_INCLUDE_DIR})
|
||||
set(IMGUI_${NAME}_X86_INCLUDE_DIR ${${NAME}_INCLUDE_DIR} PARENT_SCOPE)
|
||||
get_filename_component(${NAME}_X86_LIB_DIR "${${NAME}_X86_LIBRARY}" DIRECTORY)
|
||||
set(IMGUI_${NAME}_X86_LIB_DIR ${${NAME}_X86_LIB_DIR})
|
||||
set(IMGUI_${NAME}_X86_LIB_DIR ${${NAME}_X86_LIB_DIR} PARENT_SCOPE)
|
||||
set(IMGUI_${NAME}_X86_LIBRARIES ${LIBS_NAMES})
|
||||
set(IMGUI_${NAME}_X86_LIBRARIES ${LIBS_NAMES} PARENT_SCOPE)
|
||||
endif ()
|
||||
else ()
|
||||
find_library(${NAME}_X64_LIBRARY ${LIBS_NAMES}
|
||||
PATHS "$ENV{WindowsSdkDir}/Lib/$ENV{WindowsSDKVersion}"
|
||||
PATH_SUFFIXES um/x64
|
||||
NO_CACHE
|
||||
NO_DEFAULT_PATH)
|
||||
|
||||
if (NOT ${${NAME}_INCLUDE_DIR} STREQUAL "" AND NOT ${${NAME}_X64_LIBRARY} STREQUAL "")
|
||||
set(HAS_IMGUI_${NAME}_X64 ON)
|
||||
set(HAS_IMGUI_${NAME}_X64 ON PARENT_SCOPE)
|
||||
set(IMGUI_${NAME}_X64_INCLUDE_DIR ${${NAME}_INCLUDE_DIR})
|
||||
set(IMGUI_${NAME}_X64_INCLUDE_DIR ${${NAME}_INCLUDE_DIR} PARENT_SCOPE)
|
||||
get_filename_component(${NAME}_X64_LIB_DIR "${${NAME}_X64_LIBRARY}" DIRECTORY)
|
||||
set(IMGUI_${NAME}_X64_LIB_DIR ${${NAME}_X64_LIB_DIR})
|
||||
set(IMGUI_${NAME}_X64_LIB_DIR ${${NAME}_X64_LIB_DIR} PARENT_SCOPE)
|
||||
set(IMGUI_${NAME}_X64_LIBRARIES ${LIBS_NAMES})
|
||||
set(IMGUI_${NAME}_X64_LIBRARIES ${LIBS_NAMES} PARENT_SCOPE)
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
|
||||
if (MSVC)
|
||||
find_directx(DIRECTX_9 d3d.h d3d9)
|
||||
find_directx(DIRECTX_10 d3d10.h "d3d10;d3dcompiler")
|
||||
find_directx(DIRECTX_11 d3d11.h "d3d11;d3dcompiler")
|
||||
find_directx(DIRECTX_12 d3d12.h "d3d12;d3dcompiler;dxgi")
|
||||
|
||||
if (${HAS_IMGUI_DIRECTX_9_X64})
|
||||
message(STATUS "Found DirectX 9 x64")
|
||||
else ()
|
||||
message(WARNING "DirectX 9 x64 not found")
|
||||
endif ()
|
||||
if (${HAS_IMGUI_DIRECTX_9_X86})
|
||||
message(STATUS "Found DirectX 9 x86")
|
||||
else ()
|
||||
message(WARNING "DirectX 9 x86 not found")
|
||||
endif ()
|
||||
|
||||
if (${HAS_IMGUI_DIRECTX_10_X64})
|
||||
message(STATUS "Found DirectX 10 x64")
|
||||
else ()
|
||||
message(WARNING "DirectX 10 x64 not found")
|
||||
endif ()
|
||||
if (${HAS_IMGUI_DIRECTX_10_X86})
|
||||
message(STATUS "Found DirectX 10 x86")
|
||||
else ()
|
||||
message(WARNING "DirectX 10 x86 not found")
|
||||
endif ()
|
||||
|
||||
if (${HAS_IMGUI_DIRECTX_11_X64})
|
||||
message(STATUS "Found DirectX 11 x64")
|
||||
else ()
|
||||
message(WARNING "DirectX 11 x64 not found")
|
||||
endif ()
|
||||
if (${HAS_IMGUI_DIRECTX_11_X86})
|
||||
message(STATUS "Found DirectX 11 x86")
|
||||
else ()
|
||||
message(WARNING "DirectX 11 x86 not found")
|
||||
endif ()
|
||||
|
||||
if (${HAS_IMGUI_DIRECTX_12_X64})
|
||||
message(STATUS "Found DirectX 12 x64")
|
||||
else ()
|
||||
message(WARNING "DirectX 12 x64 not found")
|
||||
endif ()
|
||||
if (${HAS_IMGUI_DIRECTX_12_X86})
|
||||
message(STATUS "Found DirectX 12 x86")
|
||||
else ()
|
||||
message(WARNING "DirectX 12 x86 not found")
|
||||
endif ()
|
||||
endif ()
|
||||
100
backends/cmake/ListBackends.cmake
Normal file
100
backends/cmake/ListBackends.cmake
Normal file
|
|
@ -0,0 +1,100 @@
|
|||
|
||||
set(FOUND_BACKENDS "")
|
||||
if (glfw3_FOUND AND OpenGL_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "glfw_opengl2" "glfw_opengl3")
|
||||
endif ()
|
||||
if (glfw3_FOUND AND Vulkan_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "glfw_vulkan")
|
||||
endif ()
|
||||
if (SDL2_FOUND AND NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
list(APPEND FOUND_BACKENDS "sdl2_sdlrenderer2")
|
||||
endif ()
|
||||
if (SDL2_FOUND AND OpenGL_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "sdl2_opengl2" "sdl2_opengl3")
|
||||
endif ()
|
||||
if (SDL2_FOUND AND Vulkan_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "sdl2_vulkan")
|
||||
endif ()
|
||||
if (SDL3_FOUND AND OpenGL_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "sdl3_opengl3")
|
||||
endif ()
|
||||
if (SDL3_FOUND AND NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
list(APPEND FOUND_BACKENDS "sdl3_sdlgpu3" "sdl3_sdlrenderer3")
|
||||
endif ()
|
||||
if (SDL3_FOUND AND HAS_IMGUI_EMSCRIPTEN)
|
||||
list(APPEND FOUND_BACKENDS "sdl3_sdlrenderer3_emscripten")
|
||||
endif ()
|
||||
if (SDL3_FOUND AND Vulkan_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "sdl3_vulkan")
|
||||
endif ()
|
||||
if (Allegro_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "allegro5")
|
||||
endif ()
|
||||
if (HAS_IMGUI_GLUT AND OpenGL_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "glut_opengl2")
|
||||
endif ()
|
||||
if (HAS_IMGUI_EMSCRIPTEN)
|
||||
list(APPEND FOUND_BACKENDS "glfw_wgpu_emscripten" "glfw_opengl3_emscripten" "sdl2_opengl3_emscripten" "sdl3_opengl3_emscripten")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DAWN AND glfw3_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "glfw_wgpu_dawn")
|
||||
endif ()
|
||||
if (HAS_IMGUI_EMSCRIPTEN AND glfw3_FOUND AND OpenGL_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "glfw_web_opengl3")
|
||||
endif ()
|
||||
if (ANDROID_NDK)
|
||||
list(APPEND FOUND_BACKENDS "android_opengl3")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_9_X86)
|
||||
list(APPEND FOUND_BACKENDS "win32_directx9")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_10_X86)
|
||||
list(APPEND FOUND_BACKENDS "win32_directx10")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_11_X86)
|
||||
list(APPEND FOUND_BACKENDS "win32_directx11")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_12_X86)
|
||||
list(APPEND FOUND_BACKENDS "win32_directx12")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_9_X64)
|
||||
list(APPEND FOUND_BACKENDS "win64_directx9")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_10_X64)
|
||||
list(APPEND FOUND_BACKENDS "win64_directx10")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_11_X64)
|
||||
list(APPEND FOUND_BACKENDS "win64_directx11")
|
||||
endif ()
|
||||
if (HAS_IMGUI_DIRECTX_12_X64)
|
||||
list(APPEND FOUND_BACKENDS "win64_directx12")
|
||||
endif ()
|
||||
if (MSVC)
|
||||
if (OpenGL_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "win32_opengl3")
|
||||
endif ()
|
||||
if (Vulkan_FOUND)
|
||||
list(APPEND FOUND_BACKENDS "win32_vulkan")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set(SUPPORTED_BACKENDS ${FOUND_BACKENDS})
|
||||
set(SUPPORTED_BACKENDS ${FOUND_BACKENDS} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_GLFW3 ${HAS_IMGUI_GLFW3} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_OPENGL ${HAS_IMGUI_OPENGL} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_SDL2 ${HAS_IMGUI_SDL2} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_SDL3 ${HAS_IMGUI_SDL3} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_VULKAN ${HAS_IMGUI_VULKAN} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_ALLEGRO ${HAS_IMGUI_ALLEGRO} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_GLUT ${HAS_IMGUI_GLUT} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_EMSCRIPTEN ${HAS_IMGUI_EMSCRIPTEN} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DAWN ${HAS_IMGUI_DAWN} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_9_X64 ${HAS_IMGUI_DIRECTX_9_X64} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_9_X86 ${HAS_IMGUI_DIRECTX_9_X86} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_10_X64 ${HAS_IMGUI_DIRECTX_10_X64} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_10_X86 ${HAS_IMGUI_DIRECTX_10_X86} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_11_X64 ${HAS_IMGUI_DIRECTX_11_X64} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_11_X86 ${HAS_IMGUI_DIRECTX_11_X86} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_12_X64 ${HAS_IMGUI_DIRECTX_12_X64} PARENT_SCOPE)
|
||||
set(HAS_IMGUI_DIRECTX_12_X86 ${HAS_IMGUI_DIRECTX_12_X86} PARENT_SCOPE)
|
||||
message(STATUS "Supported backends ${SUPPORTED_BACKENDS}")
|
||||
62
cmake/imguiConfig.cmake.in
Normal file
62
cmake/imguiConfig.cmake.in
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
@PACKAGE_INIT@
|
||||
|
||||
set(SUPPORTED_BACKENDS "@SUPPORTED_BACKENDS@")
|
||||
set(HAS_IMGUI_EMSCRIPTEN "@HAS_IMGUI_EMSCRIPTEN@")
|
||||
set(HAS_IMGUI_DAWN "@HAS_IMGUI_DAWN@")
|
||||
set(HAS_IMGUI_ALLEGRO "@HAS_IMGUI_ALLEGRO@")
|
||||
set(HAS_IMGUI_GLFW "@HAS_IMGUI_GLFW3@")
|
||||
set(HAS_IMGUI_GLUT "@HAS_IMGUI_GLUT@")
|
||||
set(HAS_IMGUI_OPENGL "@HAS_IMGUI_OPENGL@")
|
||||
set(HAS_IMGUI_SDL2 "@HAS_IMGUI_SDL2@")
|
||||
set(HAS_IMGUI_SDL3 "@HAS_IMGUI_SDL3@")
|
||||
set(HAS_IMGUI_VULKAN "@HAS_IMGUI_VULKAN@")
|
||||
set(HAS_IMGUI_DIRECTX_9_X64 "@HAS_IMGUI_DIRECTX_9_X64@")
|
||||
set(HAS_IMGUI_DIRECTX_9_X86 "@HAS_IMGUI_DIRECTX_9_X86@")
|
||||
set(HAS_IMGUI_DIRECTX_10_X64 "@HAS_IMGUI_DIRECTX_10_X64@")
|
||||
set(HAS_IMGUI_DIRECTX_10_X86 "@HAS_IMGUI_DIRECTX_10_X86@")
|
||||
set(HAS_IMGUI_DIRECTX_11_X64 "@HAS_IMGUI_DIRECTX_11_X64@")
|
||||
set(HAS_IMGUI_DIRECTX_11_X86 "@HAS_IMGUI_DIRECTX_11_X86@")
|
||||
set(HAS_IMGUI_DIRECTX_12_X64 "@HAS_IMGUI_DIRECTX_12_X64@")
|
||||
set(HAS_IMGUI_DIRECTX_12_X86 "@HAS_IMGUI_DIRECTX_12_X86@")
|
||||
set(WITH_FREETYPE "@WITH_FREETYPE@")
|
||||
|
||||
if (HAS_IMGUI_GLFW)
|
||||
find_package(glfw3 REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_OPENGL)
|
||||
find_package(OpenGL REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_SDL2)
|
||||
find_package(SDL2 REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_SDL3)
|
||||
find_package(SDL3 REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_VULKAN)
|
||||
find_package(Vulkan REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_ALLEGRO)
|
||||
find_package(Allegro REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_GLUT)
|
||||
find_package(GLUT QUIET)
|
||||
if (NOT GLUT_FOUND)
|
||||
find_package(FreeGLUT REQUIRED)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_DAWN)
|
||||
find_package(Dawn REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (WITH_FREETYPE AND NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
find_package(freetype REQUIRED CONFIG)
|
||||
endif ()
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/imguiTargets.cmake")
|
||||
82
examples/CMakeLists.txt
Normal file
82
examples/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
add_subdirectory(example_null)
|
||||
if ("glfw_opengl2" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_glfw_opengl2)
|
||||
endif ()
|
||||
if ("glfw_opengl3" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "glfw_opengl3_emscripten" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_glfw_opengl3)
|
||||
endif ()
|
||||
if ("glfw_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_glfw_vulkan)
|
||||
endif ()
|
||||
if ("sdl2_opengl2" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_sdl2_opengl2)
|
||||
endif ()
|
||||
if ("sdl2_opengl3" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "sdl2_opengl3_emscripten" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_sdl2_opengl3)
|
||||
endif ()
|
||||
if ("sdl2_sdlrenderer2" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_sdl2_sdlrenderer2)
|
||||
endif ()
|
||||
if ("sdl2_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_sdl2_vulkan)
|
||||
endif ()
|
||||
if ("sdl3_opengl3" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "sdl3_opengl3_emscripten" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_sdl3_opengl3)
|
||||
endif ()
|
||||
if ("sdl3_sdlgpu3" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_sdl3_sdlgpu3)
|
||||
endif ()
|
||||
if ("sdl3_sdlrenderer3" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "sdl3_sdlrenderer3_emscripten" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_sdl3_sdlrenderer3)
|
||||
endif ()
|
||||
if ("sdl3_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_sdl3_vulkan)
|
||||
endif ()
|
||||
if ("allegro5" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_allegro5)
|
||||
endif ()
|
||||
if ("glut_opengl2" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_glut_opengl2)
|
||||
endif ()
|
||||
if ("android_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_android_opengl3)
|
||||
endif ()
|
||||
if ("glfw_wgpu_emscripten" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "glfw_wgpu_dawn" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_glfw_wgpu)
|
||||
endif ()
|
||||
if ("win32_directx9" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "win64_directx9" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_win32_directx9)
|
||||
endif ()
|
||||
if ("win32_directx10" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "win64_directx10" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_win32_directx10)
|
||||
endif ()
|
||||
if ("win32_directx11" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "win64_directx11" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_win32_directx11)
|
||||
endif ()
|
||||
if ("win32_directx12" IN_LIST SUPPORTED_BACKENDS
|
||||
OR "win64_directx12" IN_LIST SUPPORTED_BACKENDS
|
||||
)
|
||||
add_subdirectory(example_win32_directx12)
|
||||
endif ()
|
||||
if ("win32_opengl3" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_win32_opengl3)
|
||||
endif ()
|
||||
if ("win32_vulkan" IN_LIST SUPPORTED_BACKENDS)
|
||||
add_subdirectory(example_win32_vulkan)
|
||||
endif ()
|
||||
10
examples/example_allegro5/CMakeLists.txt
Normal file
10
examples/example_allegro5/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_allegro5)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui_alegro imgui::backend_allegro5)
|
||||
|
|
@ -165,7 +165,7 @@
|
|||
<ClCompile Include="..\..\imgui_tables.cpp" />
|
||||
<ClCompile Include="..\..\imgui_widgets.cpp" />
|
||||
<ClCompile Include="..\..\backends\imgui_impl_allegro5.cpp" />
|
||||
<ClCompile Include="imconfig_allegro5.h" />
|
||||
<ClCompile Include="..\..\backends\imconfig_allegro5.h" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
<ClCompile Include="..\..\backends\imgui_impl_allegro5.cpp">
|
||||
<Filter>sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="imconfig_allegro5.h">
|
||||
<ClCompile Include="..\..\backends\imconfig_allegro5.h">
|
||||
<Filter>sources</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\imgui_tables.cpp">
|
||||
|
|
|
|||
|
|
@ -1,40 +1,15 @@
|
|||
cmake_minimum_required(VERSION 3.6)
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_android_opengl3)
|
||||
|
||||
project(ImGuiExample)
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
add_library(${PROJECT_NAME} SHARED)
|
||||
|
||||
add_library(${CMAKE_PROJECT_NAME} SHARED
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../imgui.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_demo.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_draw.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_tables.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../imgui_widgets.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../backends/imgui_impl_android.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../backends/imgui_impl_opengl3.cpp
|
||||
${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c
|
||||
)
|
||||
target_sources(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
FILE_SET HEADERS FILES ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.h
|
||||
BASE_DIRS ${ANDROID_NDK}/sources/android/native_app_glue
|
||||
PRIVATE
|
||||
main.cpp ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS
|
||||
"${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate"
|
||||
)
|
||||
|
||||
target_compile_definitions(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
IMGUI_IMPL_OPENGL_ES3
|
||||
)
|
||||
|
||||
target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../../backends
|
||||
${ANDROID_NDK}/sources/android/native_app_glue
|
||||
)
|
||||
|
||||
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
android
|
||||
EGL
|
||||
GLESv3
|
||||
log
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_android_opengl3)
|
||||
|
|
|
|||
10
examples/example_glfw_opengl2/CMakeLists.txt
Normal file
10
examples/example_glfw_opengl2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_glfw_opengl2)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_glfw_opengl2)
|
||||
44
examples/example_glfw_opengl3/CMakeLists.txt
Normal file
44
examples/example_glfw_opengl3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_glfw_opengl3)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_glfw_opengl3)
|
||||
else ()
|
||||
add_executable(example_glfw_opengl3_emscripten)
|
||||
|
||||
target_sources(example_glfw_opengl3_emscripten PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_glfw_opengl3_emscripten PRIVATE imgui::imgui imgui::backend_glfw_opengl3_emscripten)
|
||||
|
||||
target_link_options(example_glfw_opengl3_emscripten
|
||||
PRIVATE
|
||||
"--shell-file=${CMAKE_CURRENT_SOURCE_DIR}/../libs/emscripten/shell_minimal.html"
|
||||
"-sMODULARIZE=0"
|
||||
)
|
||||
|
||||
set_target_properties(example_glfw_opengl3_emscripten PROPERTIES OUTPUT_NAME "index")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
if (IMGUI_HTTP_PORT)
|
||||
set(HTTP_PORT ${IMGUI_HTTP_PORT})
|
||||
else ()
|
||||
set(HTTP_PORT 8080)
|
||||
endif ()
|
||||
if (IMGUI_HTTP_ADDRESS)
|
||||
set(HTTP_ADDRESS ${IMGUI_HTTP_ADDRESS})
|
||||
else ()
|
||||
set(HTTP_ADDRESS 127.0.0.1)
|
||||
endif ()
|
||||
add_custom_target(run_example_glfw_opengl3_emscripten
|
||||
COMMAND python -m http.server -b ${HTTP_ADDRESS} -d $<TARGET_FILE_DIR:example_glfw_opengl3_emscripten> ${HTTP_PORT}
|
||||
DEPENDS example_glfw_opengl3_emscripten
|
||||
COMMENT "Run a python http.server in example_glfw_opengl3_emscripten location http://${HTTP_ADDRESS}:${HTTP_PORT}/"
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif ()
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
static void glfw_error_callback(int error, const char* description)
|
||||
|
|
|
|||
|
|
@ -1,47 +1,11 @@
|
|||
# Example usage:
|
||||
# mkdir build
|
||||
# cd build
|
||||
# cmake -g "Visual Studio 14 2015" ..
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_glfw_vulkan)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(imgui_example_glfw_vulkan C CXX)
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
||||
endif()
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DVK_PROTOTYPES")
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_PROTOTYPES")
|
||||
|
||||
# GLFW
|
||||
if(NOT GLFW_DIR)
|
||||
set(GLFW_DIR ../../../glfw) # Set this to point to an up-to-date GLFW repo
|
||||
endif()
|
||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
|
||||
option(GLFW_INSTALL "Generate installation target" OFF)
|
||||
option(GLFW_DOCUMENT_INTERNALS "Include internals in documentation" OFF)
|
||||
add_subdirectory(${GLFW_DIR} binary_dir EXCLUDE_FROM_ALL)
|
||||
include_directories(${GLFW_DIR}/include)
|
||||
|
||||
# Dear ImGui
|
||||
set(IMGUI_DIR ../../)
|
||||
include_directories(${IMGUI_DIR} ${IMGUI_DIR}/backends ..)
|
||||
|
||||
# Libraries
|
||||
find_package(Vulkan REQUIRED)
|
||||
#find_library(VULKAN_LIBRARY
|
||||
#NAMES vulkan vulkan-1)
|
||||
#set(LIBRARIES "glfw;${VULKAN_LIBRARY}")
|
||||
set(LIBRARIES "glfw;Vulkan::Vulkan")
|
||||
|
||||
# Use vulkan headers from glfw:
|
||||
include_directories(${GLFW_DIR}/deps)
|
||||
|
||||
file(GLOB sources *.cpp)
|
||||
|
||||
add_executable(example_glfw_vulkan ${sources} ${IMGUI_DIR}/backends/imgui_impl_glfw.cpp ${IMGUI_DIR}/backends/imgui_impl_vulkan.cpp ${IMGUI_DIR}/imgui.cpp ${IMGUI_DIR}/imgui_draw.cpp ${IMGUI_DIR}/imgui_demo.cpp ${IMGUI_DIR}/imgui_tables.cpp ${IMGUI_DIR}/imgui_widgets.cpp)
|
||||
target_link_libraries(example_glfw_vulkan ${LIBRARIES})
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE "VK_PROTOTYPES")
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_glfw_vulkan)
|
||||
|
|
|
|||
|
|
@ -1,117 +1,62 @@
|
|||
# Building for desktop (WebGPU-native) with Dawn:
|
||||
# 1. git clone https://github.com/google/dawn dawn
|
||||
# 2. cmake -B build -DIMGUI_DAWN_DIR=dawn
|
||||
# 3. cmake --build build
|
||||
# 2. cd dawn
|
||||
# command 3. will install at <dawn>/cmake-build-debug-clang/install, it takes a while
|
||||
# 3. CC=clang CXX=clang++ cmake -DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" -B cmake-build-debug-clang -S . -DDAWN_ENABLE_INSTALL=ON -DCMAKE_INSTALL_PREFIX=cmake-build-debug-clang/install -DBUILD_SAMPLES=OFF -DDAWN_FETCH_DEPENDENCIES=ON -DDAWN_USE_GLFW=ON -DDAWN_ENABLE_VULKAN=ON -DTINT_BUILD_CMD_TOOLS=OFF -DTINT_BUILD_TESTS=OFF -DDAWN_ENABLE_SPIRV_VALIDATION=OFF
|
||||
# build ImGui with Dawn
|
||||
# 4. cmake -B build -DDawn_DIR=<dawn>/cmake-build-debug-clang/install/lib/cmake/Dawn
|
||||
# 5. cmake --build build --target example_glfw_wgpu_dawn
|
||||
# The resulting binary will be found at one of the following locations:
|
||||
# * build/Debug/example_glfw_wgpu[.exe]
|
||||
# * build/example_glfw_wgpu[.exe]
|
||||
# * build/Debug/example_glfw_wgpu_dawn[.exe]
|
||||
# * build/example_glfw_wgpu_dawn[.exe]
|
||||
|
||||
# Building for Emscripten:
|
||||
# 1. Install Emscripten SDK following the instructions: https://emscripten.org/docs/getting_started/downloads.html
|
||||
# 2. Install Ninja build system
|
||||
# 3. emcmake cmake -G Ninja -B build
|
||||
# 3. cmake --build build
|
||||
# 3. cmake --build build --target example_glfw_wgpu_emscripten
|
||||
# 4. emrun build/index.html
|
||||
|
||||
cmake_minimum_required(VERSION 3.10.2)
|
||||
project(imgui_example_glfw_wgpu C CXX)
|
||||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_glfw_wgpu)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Debug CACHE STRING "" FORCE)
|
||||
endif()
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17) # Dawn requires C++17
|
||||
if (HAS_IMGUI_DAWN AND 0) # example does not compile with latest Dawn
|
||||
add_executable(example_glfw_wgpu_dawn)
|
||||
|
||||
# Dear ImGui
|
||||
set(IMGUI_DIR ../../)
|
||||
target_sources(example_glfw_wgpu_dawn PRIVATE main.cpp)
|
||||
|
||||
# Libraries
|
||||
if(EMSCRIPTEN)
|
||||
if(EMSCRIPTEN_VERSION VERSION_GREATER_EQUAL "3.1.57")
|
||||
set(IMGUI_EMSCRIPTEN_GLFW3 "--use-port=contrib.glfw3" CACHE STRING "Choose between --use-port=contrib.glfw3 and -sUSE_GLFW=3 for GLFW implementation (default to --use-port=contrib.glfw3)")
|
||||
else()
|
||||
# cannot use contrib.glfw3 prior to 3.1.57
|
||||
set(IMGUI_EMSCRIPTEN_GLFW3 "-sUSE_GLFW=3" CACHE STRING "Use -sUSE_GLFW=3 for GLFW implementation" FORCE)
|
||||
endif()
|
||||
set(LIBRARIES glfw)
|
||||
add_compile_options(-sDISABLE_EXCEPTION_CATCHING=1 -DIMGUI_DISABLE_FILE_FUNCTIONS=1)
|
||||
else()
|
||||
# Dawn wgpu desktop
|
||||
set(DAWN_FETCH_DEPENDENCIES ON)
|
||||
set(IMGUI_DAWN_DIR CACHE PATH "Path to Dawn repository")
|
||||
if (NOT IMGUI_DAWN_DIR)
|
||||
message(FATAL_ERROR "Please specify the Dawn repository by setting IMGUI_DAWN_DIR")
|
||||
endif()
|
||||
target_link_libraries(example_glfw_wgpu_dawn PRIVATE imgui::imgui imgui::backend_glfw_wgpu_dawn)
|
||||
endif ()
|
||||
|
||||
option(DAWN_FETCH_DEPENDENCIES "Use fetch_dawn_dependencies.py as an alternative to using depot_tools" ON)
|
||||
if (HAS_IMGUI_EMSCRIPTEN)
|
||||
add_executable(example_glfw_wgpu_emscripten)
|
||||
|
||||
# Dawn builds many things by default - disable things we don't need
|
||||
option(DAWN_BUILD_SAMPLES "Enables building Dawn's samples" OFF)
|
||||
option(TINT_BUILD_CMD_TOOLS "Build the Tint command line tools" OFF)
|
||||
option(TINT_BUILD_DOCS "Build documentation" OFF)
|
||||
option(TINT_BUILD_TESTS "Build tests" OFF)
|
||||
if (NOT APPLE)
|
||||
option(TINT_BUILD_MSL_WRITER "Build the MSL output writer" OFF)
|
||||
endif()
|
||||
if(WIN32)
|
||||
option(TINT_BUILD_SPV_READER "Build the SPIR-V input reader" OFF)
|
||||
option(TINT_BUILD_WGSL_READER "Build the WGSL input reader" ON)
|
||||
option(TINT_BUILD_GLSL_WRITER "Build the GLSL output writer" OFF)
|
||||
option(TINT_BUILD_GLSL_VALIDATOR "Build the GLSL output validator" OFF)
|
||||
option(TINT_BUILD_SPV_WRITER "Build the SPIR-V output writer" OFF)
|
||||
option(TINT_BUILD_WGSL_WRITER "Build the WGSL output writer" ON)
|
||||
endif()
|
||||
target_sources(example_glfw_wgpu_emscripten PRIVATE main.cpp)
|
||||
|
||||
add_subdirectory("${IMGUI_DAWN_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/dawn" EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(example_glfw_wgpu_emscripten PRIVATE imgui::imgui imgui::backend_glfw_wgpu_emscripten)
|
||||
|
||||
set(LIBRARIES webgpu_dawn webgpu_cpp webgpu_glfw glfw)
|
||||
endif()
|
||||
|
||||
add_executable(example_glfw_wgpu
|
||||
main.cpp
|
||||
# backend files
|
||||
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
|
||||
${IMGUI_DIR}/backends/imgui_impl_wgpu.cpp
|
||||
# Dear ImGui files
|
||||
${IMGUI_DIR}/imgui.cpp
|
||||
${IMGUI_DIR}/imgui_draw.cpp
|
||||
${IMGUI_DIR}/imgui_demo.cpp
|
||||
${IMGUI_DIR}/imgui_tables.cpp
|
||||
${IMGUI_DIR}/imgui_widgets.cpp
|
||||
)
|
||||
IF(NOT EMSCRIPTEN)
|
||||
target_compile_definitions(example_glfw_wgpu PUBLIC
|
||||
"IMGUI_IMPL_WEBGPU_BACKEND_DAWN"
|
||||
)
|
||||
endif()
|
||||
target_include_directories(example_glfw_wgpu PUBLIC
|
||||
${IMGUI_DIR}
|
||||
${IMGUI_DIR}/backends
|
||||
)
|
||||
|
||||
target_link_libraries(example_glfw_wgpu PUBLIC ${LIBRARIES})
|
||||
|
||||
# Emscripten settings
|
||||
if(EMSCRIPTEN)
|
||||
if("${IMGUI_EMSCRIPTEN_GLFW3}" STREQUAL "--use-port=contrib.glfw3")
|
||||
target_compile_options(example_glfw_wgpu PUBLIC
|
||||
"${IMGUI_EMSCRIPTEN_GLFW3}"
|
||||
set_target_properties(example_glfw_wgpu_emscripten PROPERTIES OUTPUT_NAME "index")
|
||||
# copy our custom index.html to build directory
|
||||
add_custom_command(TARGET example_glfw_wgpu_emscripten POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/web/index.html" $<TARGET_FILE_DIR:example_glfw_wgpu_emscripten>
|
||||
)
|
||||
endif()
|
||||
message(STATUS "Using ${IMGUI_EMSCRIPTEN_GLFW3} GLFW implementation")
|
||||
target_link_options(example_glfw_wgpu PRIVATE
|
||||
"-sUSE_WEBGPU=1"
|
||||
"${IMGUI_EMSCRIPTEN_GLFW3}"
|
||||
"-sWASM=1"
|
||||
"-sALLOW_MEMORY_GROWTH=1"
|
||||
"-sNO_EXIT_RUNTIME=0"
|
||||
"-sASSERTIONS=1"
|
||||
"-sDISABLE_EXCEPTION_CATCHING=1"
|
||||
"-sNO_FILESYSTEM=1"
|
||||
)
|
||||
set_target_properties(example_glfw_wgpu PROPERTIES OUTPUT_NAME "index")
|
||||
# copy our custom index.html to build directory
|
||||
add_custom_command(TARGET example_glfw_wgpu POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_LIST_DIR}/web/index.html" $<TARGET_FILE_DIR:example_glfw_wgpu>
|
||||
)
|
||||
endif()
|
||||
|
||||
if (IMGUI_HTTP_PORT)
|
||||
set(HTTP_PORT ${IMGUI_HTTP_PORT})
|
||||
else ()
|
||||
set(HTTP_PORT 8080)
|
||||
endif ()
|
||||
if (IMGUI_HTTP_ADDRESS)
|
||||
set(HTTP_ADDRESS ${IMGUI_HTTP_ADDRESS})
|
||||
else ()
|
||||
set(HTTP_ADDRESS 127.0.0.1)
|
||||
endif ()
|
||||
add_custom_target(run_example_glfw_wgpu_emscripten
|
||||
COMMAND python -m http.server -b ${HTTP_ADDRESS} -d $<TARGET_FILE_DIR:example_glfw_wgpu_emscripten> ${HTTP_PORT}
|
||||
DEPENDS example_glfw_wgpu_emscripten
|
||||
COMMENT "Run a python http.server in example_glfw_wgpu_emscripten location http://${HTTP_ADDRESS}:${HTTP_PORT}/"
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif ()
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
// Global WebGPU required states
|
||||
|
|
|
|||
10
examples/example_glut_opengl2/CMakeLists.txt
Normal file
10
examples/example_glut_opengl2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_glut_opengl2)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_glut_opengl2)
|
||||
9
examples/example_null/CMakeLists.txt
Normal file
9
examples/example_null/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Important: This is a "null backend" application, with no visible output or interaction!
|
||||
# This is used for testing purpose and continuous integration, and has little use for end-user.
|
||||
#
|
||||
|
||||
add_library(example_null STATIC)
|
||||
|
||||
target_sources(example_null PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_null PRIVATE imgui::imgui)
|
||||
10
examples/example_sdl2_opengl2/CMakeLists.txt
Normal file
10
examples/example_sdl2_opengl2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl2_opengl2)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl2_opengl2)
|
||||
44
examples/example_sdl2_opengl3/CMakeLists.txt
Normal file
44
examples/example_sdl2_opengl3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl2_opengl3)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl2_opengl3)
|
||||
else ()
|
||||
add_executable(example_sdl2_opengl3_emscripten)
|
||||
|
||||
target_sources(example_sdl2_opengl3_emscripten PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_sdl2_opengl3_emscripten PRIVATE imgui::imgui imgui::backend_sdl2_opengl3_emscripten)
|
||||
|
||||
target_link_options(example_sdl2_opengl3_emscripten
|
||||
PRIVATE
|
||||
"--shell-file=${CMAKE_CURRENT_SOURCE_DIR}/../libs/emscripten/shell_minimal.html"
|
||||
"-sMODULARIZE=0"
|
||||
)
|
||||
|
||||
set_target_properties(example_sdl2_opengl3_emscripten PROPERTIES OUTPUT_NAME "index")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
if (IMGUI_HTTP_PORT)
|
||||
set(HTTP_PORT ${IMGUI_HTTP_PORT})
|
||||
else ()
|
||||
set(HTTP_PORT 8080)
|
||||
endif ()
|
||||
if (IMGUI_HTTP_ADDRESS)
|
||||
set(HTTP_ADDRESS ${IMGUI_HTTP_ADDRESS})
|
||||
else ()
|
||||
set(HTTP_ADDRESS 127.0.0.1)
|
||||
endif ()
|
||||
add_custom_target(run_example_sdl2_opengl3_emscripten
|
||||
COMMAND python -m http.server -b ${HTTP_ADDRESS} -d $<TARGET_FILE_DIR:example_sdl2_opengl3_emscripten> ${HTTP_PORT}
|
||||
DEPENDS example_sdl2_opengl3_emscripten
|
||||
COMMENT "Run a python http.server in example_sdl2_opengl3_emscripten location http://${HTTP_ADDRESS}:${HTTP_PORT}/"
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif ()
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
// This example can also compile and run with Emscripten! See 'Makefile.emscripten' for details.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
// Main code
|
||||
|
|
|
|||
11
examples/example_sdl2_sdlrenderer2/CMakeLists.txt
Normal file
11
examples/example_sdl2_sdlrenderer2/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl2_sdlrenderer2)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl2_sdlrenderer2)
|
||||
|
||||
10
examples/example_sdl2_vulkan/CMakeLists.txt
Normal file
10
examples/example_sdl2_vulkan/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl2_vulkan)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl2_vulkan)
|
||||
44
examples/example_sdl3_opengl3/CMakeLists.txt
Normal file
44
examples/example_sdl3_opengl3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl3_opengl3)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl3_opengl3)
|
||||
else ()
|
||||
add_executable(example_sdl3_opengl3_emscripten)
|
||||
|
||||
target_sources(example_sdl3_opengl3_emscripten PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_sdl3_opengl3_emscripten PRIVATE imgui::imgui imgui::backend_sdl3_opengl3_emscripten)
|
||||
|
||||
target_link_options(example_sdl3_opengl3_emscripten
|
||||
PRIVATE
|
||||
"--shell-file=${CMAKE_CURRENT_SOURCE_DIR}/../libs/emscripten/shell_minimal.html"
|
||||
"-sMODULARIZE=0"
|
||||
)
|
||||
|
||||
set_target_properties(example_sdl3_opengl3_emscripten PROPERTIES OUTPUT_NAME "index")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
if (IMGUI_HTTP_PORT)
|
||||
set(HTTP_PORT ${IMGUI_HTTP_PORT})
|
||||
else ()
|
||||
set(HTTP_PORT 8080)
|
||||
endif ()
|
||||
if (IMGUI_HTTP_ADDRESS)
|
||||
set(HTTP_ADDRESS ${IMGUI_HTTP_ADDRESS})
|
||||
else ()
|
||||
set(HTTP_ADDRESS 127.0.0.1)
|
||||
endif ()
|
||||
add_custom_target(run_example_sdl3_opengl3_emscripten
|
||||
COMMAND python -m http.server -b ${HTTP_ADDRESS} -d $<TARGET_FILE_DIR:example_sdl3_opengl3_emscripten> ${HTTP_PORT}
|
||||
DEPENDS example_sdl3_opengl3_emscripten
|
||||
COMMENT "Run a python http.server in example_sdl3_opengl3_emscripten location http://${HTTP_ADDRESS}:${HTTP_PORT}/"
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif ()
|
||||
|
|
@ -36,7 +36,7 @@ EMS =
|
|||
##---------------------------------------------------------------------
|
||||
|
||||
# ("EMS" options gets added to both CPPFLAGS and LDFLAGS, whereas some options are for linker only)
|
||||
EMS += -s USE_SDL=2
|
||||
EMS += -s USE_SDL=3
|
||||
EMS += -s DISABLE_EXCEPTION_CATCHING=1
|
||||
LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS=1
|
||||
|
||||
|
|
@ -50,8 +50,9 @@ LDFLAGS += -s WASM=1 -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=0 -s ASSERTIONS
|
|||
# Emscripten allows preloading a file or folder to be accessible at runtime.
|
||||
# The Makefile for this example project suggests embedding the misc/fonts/ folder into our application, it will then be accessible as "/fonts"
|
||||
# See documentation for more details: https://emscripten.org/docs/porting/files/packaging_files.html
|
||||
# (Default value is 0. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
|
||||
USE_FILE_SYSTEM ?= 0
|
||||
# (Default value is 1. Set to 1 to enable file-system and include the misc/fonts/ folder as part of the build.)
|
||||
# Does not compile with USE_FILE_SYSTEM=0
|
||||
USE_FILE_SYSTEM ?= 1
|
||||
ifeq ($(USE_FILE_SYSTEM), 0)
|
||||
LDFLAGS += -s NO_FILESYSTEM=1
|
||||
CPPFLAGS += -DIMGUI_DISABLE_FILE_FUNCTIONS
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#endif
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
// Main code
|
||||
|
|
|
|||
10
examples/example_sdl3_sdlgpu3/CMakeLists.txt
Normal file
10
examples/example_sdl3_sdlgpu3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl3_sdlgpu3)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl3_sdlgpu3)
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
// This example doesn't compile with Emscripten yet! Awaiting SDL3 support.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
// Main code
|
||||
|
|
|
|||
45
examples/example_sdl3_sdlrenderer3/CMakeLists.txt
Normal file
45
examples/example_sdl3_sdlrenderer3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl3_sdlrenderer3)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (NOT HAS_IMGUI_EMSCRIPTEN)
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl3_sdlrenderer3)
|
||||
|
||||
else ()
|
||||
add_executable(example_sdl3_sdlrenderer3_emscripten)
|
||||
|
||||
target_sources(example_sdl3_sdlrenderer3_emscripten PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_sdl3_sdlrenderer3_emscripten PRIVATE imgui::imgui imgui::backend_sdl3_sdlrenderer3_emscripten)
|
||||
|
||||
target_link_options(example_sdl3_sdlrenderer3_emscripten
|
||||
PRIVATE
|
||||
"--shell-file=${CMAKE_CURRENT_SOURCE_DIR}/../libs/emscripten/shell_minimal.html"
|
||||
"-sMODULARIZE=0"
|
||||
)
|
||||
|
||||
set_target_properties(example_sdl3_sdlrenderer3_emscripten PROPERTIES OUTPUT_NAME "index")
|
||||
set(CMAKE_EXECUTABLE_SUFFIX ".html")
|
||||
|
||||
if (IMGUI_HTTP_PORT)
|
||||
set(HTTP_PORT ${IMGUI_HTTP_PORT})
|
||||
else ()
|
||||
set(HTTP_PORT 8080)
|
||||
endif ()
|
||||
if (IMGUI_HTTP_ADDRESS)
|
||||
set(HTTP_ADDRESS ${IMGUI_HTTP_ADDRESS})
|
||||
else ()
|
||||
set(HTTP_ADDRESS 127.0.0.1)
|
||||
endif ()
|
||||
add_custom_target(run_example_sdl3_sdlrenderer3_emscripten
|
||||
COMMAND python -m http.server -b ${HTTP_ADDRESS} -d $<TARGET_FILE_DIR:example_sdl3_sdlrenderer3_emscripten> ${HTTP_PORT}
|
||||
DEPENDS example_sdl3_sdlrenderer3_emscripten
|
||||
COMMENT "Run a python http.server in example_sdl3_sdlrenderer3_emscripten location http://${HTTP_ADDRESS}:${HTTP_PORT}/"
|
||||
USES_TERMINAL
|
||||
)
|
||||
endif ()
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
#include <SDL3/SDL.h>
|
||||
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
// Main code
|
||||
|
|
|
|||
10
examples/example_sdl3_vulkan/CMakeLists.txt
Normal file
10
examples/example_sdl3_vulkan/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_sdl3_vulkan)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_sdl3_vulkan)
|
||||
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
// This example doesn't compile with Emscripten yet! Awaiting SDL3 support.
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#include "../libs/emscripten/emscripten_mainloop_stub.h"
|
||||
#include "emscripten_mainloop_stub.h"
|
||||
#endif
|
||||
|
||||
// Volk headers
|
||||
|
|
|
|||
20
examples/example_win32_directx10/CMakeLists.txt
Normal file
20
examples/example_win32_directx10/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_win_directx10)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_10_X86)
|
||||
add_executable(example_win32_directx10)
|
||||
|
||||
target_sources(example_win32_directx10 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win32_directx10 PRIVATE imgui::imgui imgui::backend_win32_directx10)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_10_X64)
|
||||
add_executable(example_win64_directx10)
|
||||
|
||||
target_sources(example_win64_directx10 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win64_directx10 PRIVATE imgui::imgui imgui::backend_win64_directx10)
|
||||
endif ()
|
||||
20
examples/example_win32_directx11/CMakeLists.txt
Normal file
20
examples/example_win32_directx11/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_win_directx11)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_11_X86)
|
||||
add_executable(example_win32_directx11)
|
||||
|
||||
target_sources(example_win32_directx11 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win32_directx11 PRIVATE imgui::imgui imgui::backend_win32_directx11)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_11_X64)
|
||||
add_executable(example_win64_directx11)
|
||||
|
||||
target_sources(example_win64_directx11 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win64_directx11 PRIVATE imgui::imgui imgui::backend_win64_directx11)
|
||||
endif ()
|
||||
20
examples/example_win32_directx12/CMakeLists.txt
Normal file
20
examples/example_win32_directx12/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_win_directx12)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_12_X86)
|
||||
add_executable(example_win32_directx12)
|
||||
|
||||
target_sources(example_win32_directx12 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win32_directx12 PRIVATE imgui::imgui imgui::backend_win32_directx12)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_12_X64)
|
||||
add_executable(example_win64_directx12)
|
||||
|
||||
target_sources(example_win64_directx12 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win64_directx12 PRIVATE imgui::imgui imgui::backend_win64_directx12)
|
||||
endif ()
|
||||
20
examples/example_win32_directx9/CMakeLists.txt
Normal file
20
examples/example_win32_directx9/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_win_directx9)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_9_X86)
|
||||
add_executable(example_win32_directx9)
|
||||
|
||||
target_sources(example_win32_directx9 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win32_directx9 PRIVATE imgui::imgui imgui::backend_win32_directx9)
|
||||
endif ()
|
||||
|
||||
if (HAS_IMGUI_DIRECTX_9_X64)
|
||||
add_executable(example_win64_directx9)
|
||||
|
||||
target_sources(example_win64_directx9 PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(example_win64_directx9 PRIVATE imgui::imgui imgui::backend_win64_directx9)
|
||||
endif ()
|
||||
10
examples/example_win32_opengl3/CMakeLists.txt
Normal file
10
examples/example_win32_opengl3/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_win32_opengl3)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_win32_opengl3)
|
||||
10
examples/example_win32_vulkan/CMakeLists.txt
Normal file
10
examples/example_win32_vulkan/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
cmake_minimum_required(VERSION 3.23)
|
||||
project(example_win32_vulkan)
|
||||
|
||||
# find_package(imgui REQUIRED)
|
||||
|
||||
add_executable(${PROJECT_NAME})
|
||||
|
||||
target_sources(${PROJECT_NAME} PRIVATE main.cpp)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui imgui::backend_win32_vulkan)
|
||||
Loading…
Add table
Add a link
Reference in a new issue