Skip to content

Configuring SDL with CMake twice in a row results in different compiler flags #13375

@zopsicle

Description

@zopsicle

Using clang-cl:

$ cmake -G 'Ninja Multi-Config' -B .build
$ cp -R .build backup
$ cmake -G 'Ninja Multi-Config' -B .build
$ diff -ru backup .build

this prints a whole bunch of diff lines like this:

-  FLAGS = /DWIN32 /D_WINDOWS /Ob0 /Od  -MD -Zi /W3 -Wundef -Wfloat-conversion -fno-strict-aliasing -Wdocumentation -Wdocumentation-unknown-command /clang:-fcomment-block-commands=threadsafety -Wshadow -Wno-unused-local-typedefs -Wimplicit-fallthrough -fcolor-diagnostics
+  FLAGS = /DWIN32 /D_WINDOWS /Ob0 /Od /RTC1 -MD -Zi /W3 -Wundef -Wfloat-conversion -fno-strict-aliasing -Wdocumentation -Wdocumentation-unknown-command /clang:-fcomment-block-commands=threadsafety -Wshadow -Wno-unused-local-typedefs -Wimplicit-fallthrough -fcolor-diagnostics

I think the bug is as follows:

if(NOT SDL_LIBC)

this check happens before SDL_LIBC is set. It is not set until here:

set_option(SDL_LIBC "Use the system C library" ${SDL_LIBC_DEFAULT})

The reason it works on the second configure is that SDL_LIBC is read from CMake variable cache.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions