pthom / imgui_bundle

Dear ImGui Bundle: an extensive set of Ready-to-use widgets and libraries, based on ImGui. Start your first app in 5 lines of code, or less. Whether you prefer Python or C++, this pack has your back!
https://pthom.github.io/imgui_bundle/
MIT License
667 stars 66 forks source link

Disable IMMVISION #136

Closed ramgon closed 1 year ago

ramgon commented 1 year ago

Hi! In my project imgui_bundle is included as submodule. I don't need to build either OpenCV and ImmVision, so in CMakeLists.txt I have the following lines

option(IMGUI_BUNDLE_WITH_IMMVISION OFF)
option(IMMVISION_FETCH_OPENCV OFF)

But the problem appears when building with emscripten

CMake Error at /usr/share/cmake-3.22/Modules/FetchContent.cmake:1075 (message):
  CMake step for opencv_package_emscripten failed: 1

and it is related to add_subdirectory(immvision) before if statement

# Build immvision
add_subdirectory(immvision)
if (IMGUI_BUNDLE_WITH_IMMVISION)
    target_link_libraries(imgui_bundle PUBLIC immvision)
    hello_imgui_msvc_target_group_sources(immvision)
    target_compile_definitions(imgui_bundle PUBLIC IMGUI_BUNDLE_WITH_IMMVISION)
endif()

Could you please move it inside the if body?

pthom commented 1 year ago

Hi, thanks for reaching out!

I pushed a fix for this : see https://github.com/pthom/imgui_bundle/commit/77f3f8a384de1535b55661f8185d9bbcf399ed5d

You only need to define IMMVISION_FETCH_OPENCV=OFF

Warning, your use of option is incorrect: see the doc for option, it requires 3 params, and the second is a doc string.

As a consequence option(IMMVISION_FETCH_OPENCV OFF) will not store anything in the cache, and OFF will be interpreted as the doc string. The best way to set a value from a parent cmake file is:

set(IMMVISION_FETCH_OPENCV OFF CACHE BOOL "" FORCE)

or may be

option(IMMVISION_FETCH_OPENCV ""  OFF)

(yes, this is ugly. CMake is ugly at times)

ramgon commented 1 year ago

Yes it's OK now, thank you!