CMake: Check shared libs support using properties#15795
Conversation
|
I'm not so sure removing the explicit checks is advisable, as those toolchains might not correctly report they don't support dynamic libraries. So the safest bet is to leave those checks in, then do the dynamic library support query for all other platforms. |
Looking at the CI run on my fork, it seems the property is supported on all the platforms listed in the check, however I see your point about it being risky. How about this instead: # Set the default for all platforms
get_cmake_property(SDL_SHARED_AVAILABLE TARGET_SUPPORTS_SHARED_LIBS)
...
# For platforms that are known to be static-only, make it always off regardless of what CMake thinks
if(platform_we_known_is_static_only)
set(SDL_SHARED_AVAILABLE OFF)
endif() |
That's the right idea. But the actual code could be like this: if(VITA OR PSP OR PS2 OR N3DS OR RISCOS OR NGAGE OR DOS)
set(SDL_SHARED_AVAILABLE OFF)
else()
get_cmake_property(SDL_SHARED_AVAILABLE TARGET_SUPPORTS_SHARED_LIBS)
endif()So we'd only add new hard-coded checks if the shared library support query is broken on newly supported toolchains. Though it appears the code without the hard coded checks passed CI (except OpenBSD, but that's just broken right now), so maybe the hard-coded checks aren't needed. |
|
This only works when the toolchain does DOS (djgpp) supports dynamic libraries (through dxe's) but CMake from main does not support it (yet). |
|
(I'm treating this pr as a scratchpad for the time being, when things cleared up we can remove everything through a force push) |
|
So only RISCOS, NGage and DOS are causing trouble. The ps2 toolchain contains this: |
|
Technically, Symbian does support shared libraries, however, DLLs can't have writable static data. The compiler won't report it as unsupported. |
Description
This queries CMake to check what platform support shared libraries instead of hard-coding the static-only platforms.
Existing Issue(s)
@nightmareci mentioned it on discord, dug into it and turns out it was a quick fix.