Building SDL2-2.0.8 with clang-cl


#1

Hello!

I am trying to build SDL2-2.0.8 on Windows with clang-cl, Ninja.
Unfortunately it seems like that shipped CMake scripts with SDL2 are
false detecting my compiler and trying to treat it as GCC or simple Clang.
With MSVC it builds and works. Has anyone else run into the same problem?
Are there solutions to this ?

errors:
[build] clang-cl.exe: warning: unknown argument ignored in clang-cl: ‘-idirafter’ [-Wunknown-argument]
[build] clang-cl.exe: error: cannot specify ‘/Fo_deps\sdl2-build\CMakeFiles\SDL2-static.dir\src\dynapi\SDL_dynapi.c.obj’ when compiling multiple source files

Thanks in advance!


#2

Are you telling CMake to create the makefile with native compilers? I believe that it will look for the first compiler it recognizes in your PATH variable and use that when creating the makefiles. That’s the problem I had when first attempting to use SDL2. Manually specify the compilers that you want to use, (you only need to show it 2 executables, three if you want to use Fortran), and see if that works.


#3

It finds the right compiler, which is clang-cl in our case(forced). Problem is that it is badly setting up compiler flags and has no knowledge about handling clang-cl on windows. Thats why we have the -idirafter argument passed for clang-cl. I have debugged and hacked the CMakelists.txt to make it work with clang-cl but would be good to have official support for clang-cl in SDL2.


#4

If you’re willing to post a patch to help out, I’m sure slouken or icculus would be happy to include it. They’re two of the devs for SDL that I know of.


#5

Later next week hopefully I can post my patch to use it with clang-cl :slight_smile: