eliemichel / LearnWebGPU-Code

The accompanying code of the Learn WebGPU C++ programming guide
https://eliemichel.github.io/LearnWebGPU
MIT License
114 stars 30 forks source link

C++ 11 required to compile step095 #23

Closed pierricgimmig closed 1 year ago

pierricgimmig commented 1 year ago

Compiling step095 on MacOS gives me:

In file included from /Users/pierric/git/LearnWebGPU-Code/imgui/backends/imgui_impl_wgpu.cpp:31:
/Users/pierric/git/LearnWebGPU-Code/imgui/./imgui.h:263:5: error: unknown type name 'constexpr'
    constexpr ImVec2()                      : x(0.0f), y(0.0f) { }
    ^

Adding this to CMakeLists.txt fixes compilation:

set (CMAKE_CXX_STANDARD 11)
eliemichel commented 1 year ago

Indeed on macOS clang does not enable C++11 by default, and ImGui requires it. You fiw works, a slightly better solution is to set this flag only for the imgui target, in the CMakeLists that defines it:

set_target_properties(imgui PROPERTIES
    CXX_STANDARD 11
    CXX_STANDARD_REQUIRED ON
)
pierricgimmig commented 1 year ago

Great, thanks for the fix!