Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to compile on Windows 32 bit #1

Open
qno opened this issue Feb 5, 2023 · 5 comments
Open

Fails to compile on Windows 32 bit #1

qno opened this issue Feb 5, 2023 · 5 comments

Comments

@qno
Copy link

qno commented Feb 5, 2023

Error is

[6/9] Building CXX object libs\clap-imgui-support\CMakeFiles\imgui-clap-support.dir\__\imgui\backends\imgui_impl_dx12.cpp.obj
FAILED: libs/clap-imgui-support/CMakeFiles/imgui-clap-support.dir/__/imgui/backends/imgui_impl_dx12.cpp.obj 
C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1434~1.319\bin\Hostx86\x86\cl.exe  /nologo /TP  -IC:\Users\Silvio\Desktop\test\clap-saw-demo-imgui\libs\clap-imgui-support\include -IC:\Users\Silvio\Desktop\test\clap-saw-demo-imgui\libs\imgui -IC:\Users\Silvio\Desktop\test\clap-saw-demo-imgui\libs\clap\include /DWIN32 /D_WINDOWS /GR /EHsc /Zi /Ob0 /Od /RTC1 -MTd -std:c++17 /showIncludes /Folibs\clap-imgui-support\CMakeFiles\imgui-clap-support.dir\__\imgui\backends\imgui_impl_dx12.cpp.obj /Fdlibs\clap-imgui-support\CMakeFiles\imgui-clap-support.dir\imgui-clap-support.pdb /FS -c C:\Users\Silvio\Desktop\test\clap-saw-demo-imgui\libs\imgui\backends\imgui_impl_dx12.cpp
C:\Users\Silvio\Desktop\test\clap-saw-demo-imgui\libs\imgui\backends\imgui_impl_dx12.cpp(435): error C2338: static_assert failed: 'Can't pack descriptor handle into TexID, 32-bit not supported yet.'
[7/9] Building CXX object libs\clap-imgui-support\CMakeFiles\imgui-clap-support.dir\src\win-dx12.cpp.obj

To compile this on Windows with Visual Studio you have to add the definition ImTextureID=ImU64.

...
if(WIN32)
   target_sources(${PROJECT_NAME} PRIVATE
            src/win-dx12.cpp
            ${IMGUI_SOURCE_DIR}/backends/imgui_impl_win32.cpp
            ${IMGUI_SOURCE_DIR}/backends/imgui_impl_dx12.cpp
            )
   target_compile_definitions(${PROJECT_NAME} PRIVATE ImTextureID=ImU64)
endif()

@qno
Copy link
Author

qno commented Feb 6, 2023

I figured out what is going on here, so basically it was my fault because I use Clion and used the CMake Ninja Generator.
This seems to set the platform to Win32 per default. Using Visual Studio Generator it works.

Now I'm not sure if this should be fixed, but if it could look like this

   if (NOT CMAKE_VS_PLATFORM_NAME STREQUAL "x64")
      target_compile_definitions(${PROJECT_NAME} PRIVATE ImTextureID=ImU64)
   endif ()

Or throw an CMake error that Win32 is not supported?

@baconpaul
Copy link
Contributor

I don’t understand why CLion does thst and it trips me up all the time

I think the intent is indeed to not support 32 bit windows. There’s other ways I think to get to 32 bit so I use a size of void check using the cmake_sizeof_voidp variable but we should see which frank prefers

@qno
Copy link
Author

qno commented Feb 6, 2023

It looks like it is more a problem of Ninja. I just switched to native Visual Studio Generator, which has x64 as default platform set. Clion supports also Visual Studio projects and doesn't requiere Ninja for this, so it works.

I would say that you probalby just check if target platform is not Win x64 and exit CMake with error.

@u-he-frank
Copy link
Collaborator

u-he-frank commented Feb 7, 2023

Thanks for the report. I only tested x64 builds. I see no reason to exclude 32 bit builds, as long as it doesn't make things too complicated. But what is the best way? I would prefer a positive test like

 if (CMAKE_VS_PLATFORM_NAME STREQUAL "Win32")
     target_compile_definitions(${PROJECT_NAME} PRIVATE ImTextureID=ImU64)
 endif()

or

 if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
     target_compile_definitions(${PROJECT_NAME} PRIVATE ImTextureID=ImU64)
 endif()

I am not sure which will work best?

@u-he-frank u-he-frank reopened this Feb 7, 2023
@u-he-frank u-he-frank changed the title Fails to compile on Windows Fails to compile on Windows 32 bit Feb 7, 2023
@qno
Copy link
Author

qno commented Feb 7, 2023

I know that this doesn't really belong here, but as the repo free-audio/clap-saw-demo-imgui has no issue tracker setup, I just wanted also to mention here, that you have an issue there for the Linux build at the https://github.com/free-audio/clap-saw-demo-imgui/blob/96da3ab3ed9bc9cc26eecae691db8104bd2d2f79/CMakeLists.txt#L75.

The line target_sources(${PROJECT_NAME} PRIVATE src/linux-vstgui-adapter.cpp) should be removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants