CMakeLists.txt 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. set(CMAKE_CXX_STANDARD 20)
  2. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  3. include(${IMGUI_BUNDLE_PATH}/imgui_bundle_cmake/imgui_bundle_add_demo.cmake)
  4. include_directories(.)
  5. set(demos_cpp_folder ${CMAKE_CURRENT_LIST_DIR})
  6. add_subdirectory(demo_utils)
  7. add_subdirectory(demos_immapp)
  8. add_subdirectory(demos_node_editor)
  9. add_subdirectory(demos_imguizmo)
  10. add_subdirectory(demos_tex_inspect)
  11. #add_subdirectory(demos_imanim)
  12. if(IMGUI_BUNDLE_WITH_NANOVG)
  13. add_subdirectory(demos_nanovg)
  14. endif()
  15. if (IMGUI_BUNDLE_WITH_IMMVISION)
  16. add_subdirectory(demos_immvision)
  17. endif()
  18. add_subdirectory(sandbox)
  19. ibd_add_this_folder_auto_demos("")
  20. ibd_add_this_folder_as_demos_library()
  21. target_link_libraries(demo_imguizmo_launcher PRIVATE demos_imguizmo)
  22. target_link_libraries(demo_node_editor_launcher PRIVATE demos_node_editor)
  23. target_link_libraries(demo_tex_inspect_launcher PRIVATE demos_tex_inspect)
  24. target_link_libraries(demo_imgui_bundle PRIVATE
  25. demos_cpp
  26. demos_imguizmo
  27. demos_tex_inspect
  28. demos_node_editor
  29. demo_utils
  30. )
  31. if (IMGUI_BUNDLE_WITH_IMMVISION)
  32. target_link_libraries(demo_immvision_launcher PRIVATE demos_immvision)
  33. target_link_libraries(demo_imgui_bundle PRIVATE demos_immvision)
  34. endif()
  35. if(IMMVISION_HAS_OPENCV)
  36. find_package(OpenCV REQUIRED)
  37. target_link_libraries(demo_immvision_launcher PUBLIC opencv_imgproc)
  38. target_link_libraries(demo_imgui_bundle PUBLIC opencv_imgproc)
  39. endif()
  40. FILE(COPY ../demos_assets DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  41. # Bundle demos_assets only for demos that actually need demo-specific fonts/images.
  42. # Other demos get only the core imgui_bundle_assets/ (DroidSans, Roboto, fontawesome, etc.)
  43. set(_da ${IMGUI_BUNDLE_PATH}/bindings/imgui_bundle/demos_assets)
  44. foreach(_t
  45. demo_imgui_bundle
  46. demo_imgui_bundle_intro
  47. demo_widgets
  48. demo_imgui_show_demo_window
  49. )
  50. hello_imgui_bundle_assets_from_folder(${_t} ${_da})
  51. endforeach()
  52. if (MSVC)
  53. FILE(COPY msvc_note.txt DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
  54. endif()
  55. if(EMSCRIPTEN)
  56. # Preload demo source files so that "Code for this demo" can display them.
  57. # so source files must be embedded in the virtual filesystem at /demos_cpp and /demos_python.
  58. set(_demos_root ${CMAKE_CURRENT_LIST_DIR}/..)
  59. target_link_options(demo_imgui_bundle PRIVATE
  60. "SHELL:--preload-file ${_demos_root}/demos_cpp@/demos_cpp"
  61. "SHELL:--preload-file ${_demos_root}/demos_python@/demos_python"
  62. )
  63. endif()
  64. if(EMSCRIPTEN AND HELLOIMGUI_EMSCRIPTEN_PTHREAD)
  65. # Needed addition for multithread support (required by ImGui Test Engine)
  66. # Note: see the shell.emscripten.html in this folder we are using a custom shell,
  67. # that provides Cross-origin isolation (COOP and COEP) through a service worker
  68. # for situations in which you can't control the headers (e.g. GitHub pages).
  69. #
  70. # coi-serviceworker.js was found at https://github.com/gzuidhof/coi-serviceworker, and manually patched:
  71. # see https://github.com/gzuidhof/coi-serviceworker/issues/20
  72. # and https://github.com/gzuidhof/coi-serviceworker/compare/master...tamo:coi-serviceworker:coep-ua-brand
  73. #
  74. # coi-serviceworker.js provides Cross-origin isolation (COOP and COEP) through a service worker
  75. # for situations in which you can't control the headers (e.g. GitHub pages).
  76. get_property(runtime_output_directory TARGET demo_imgui_bundle PROPERTY RUNTIME_OUTPUT_DIRECTORY)
  77. FILE(MAKE_DIRECTORY ${runtime_output_directory})
  78. FILE(COPY_FILE ${CMAKE_CURRENT_LIST_DIR}/coi-serviceworker.js ${runtime_output_directory}/coi-serviceworker.js)
  79. target_link_options(demo_imgui_bundle PUBLIC -sPTHREAD_POOL_SIZE=2)
  80. endif()