CREATE_PROJECT: Simplify feature libraries initialization

This commit is contained in:
Orgad Shaneh 2023-03-10 10:47:29 +02:00 committed by Eugene Sandulenko
parent c297d0f40f
commit 45dde26fc5
2 changed files with 20 additions and 13 deletions

View File

@ -42,22 +42,22 @@ const CMakeProvider::Library *CMakeProvider::getLibraryFromFeature(const char *f
{ "png", "libpng", kSDLVersionAny, "FindPNG", "PNG", "PNG_INCLUDE_DIRS", "PNG_LIBRARIES", nullptr },
{ "jpeg", "libjpeg", kSDLVersionAny, "FindJPEG", "JPEG", "JPEG_INCLUDE_DIRS", "JPEG_LIBRARIES", nullptr },
{ "mpeg2", "libmpeg2", kSDLVersionAny, "FindMPEG2", "MPEG2", "MPEG2_INCLUDE_DIRS", "MPEG2_mpeg2_LIBRARY", nullptr },
{ "flac", "flac", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "FLAC" },
{ "mad", "mad", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "mad" },
{ "ogg", "ogg", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "ogg" },
{ "vorbis", "vorbisfile vorbis", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "vorbisfile vorbis" },
{ "tremor", "vorbisidec", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "vorbisidec" },
{ "theoradec", "theoradec", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "theoradec" },
{ "vpx", "vpx", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "vpx" },
{ "fluidsynth", "fluidsynth", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "fluidsynth" },
{ "faad", "faad2", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "faad" },
{ "fribidi", "fribidi", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "fribidi" },
{ "discord", "discord", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "discord-rpc"},
{ "opengl", nullptr, kSDLVersionAny, "FindOpenGL", "OpenGL", "OPENGL_INCLUDE_DIR", "OPENGL_gl_LIBRARY", nullptr },
{ "libcurl", "libcurl", kSDLVersionAny, "FindCURL", "CURL", "CURL_INCLUDE_DIRS", "CURL_LIBRARIES", nullptr },
{ "sdlnet", nullptr, kSDLVersion1, "FindSDL_net", "SDL_net", "SDL_NET_INCLUDE_DIRS", "SDL_NET_LIBRARIES", nullptr },
{ "sdlnet", "SDL2_net", kSDLVersion2, nullptr, nullptr, nullptr, nullptr, "SDL2_net" },
{ "retrowave", "retrowave", kSDLVersionAny, nullptr, nullptr, nullptr, nullptr, "retrowave" }
LibraryProps("sdlnet", "SDL2_net", kSDLVersion2).Libraries("SDL2_net"),
LibraryProps("flac", "flac").Libraries("FLAC"),
LibraryProps("mad", "mad").Libraries("mad"),
LibraryProps("ogg", "ogg").Libraries("ogg"),
LibraryProps("vorbis", "vorbisfile vorbis").Libraries("vorbisfile vorbis"),
LibraryProps("tremor", "vorbisidec").Libraries("vorbisidec"),
LibraryProps("theoradec", "theoradec").Libraries("theoradec"),
LibraryProps("vpx", "vpx").Libraries("vpx"),
LibraryProps("fluidsynth", "fluidsynth").Libraries("fluidsynth"),
LibraryProps("faad", "faad2").Libraries("faad"),
LibraryProps("fribidi", "fribidi").Libraries("fribidi"),
LibraryProps("discord", "discord").Libraries("discord-rpc"),
LibraryProps("retrowave", "retrowave").Libraries("retrowave")
};
for (unsigned int i = 0; i < sizeof(s_libraries) / sizeof(s_libraries[0]); i++) {

View File

@ -75,6 +75,13 @@ private:
const char *libraries;
};
struct LibraryProps : Library {
LibraryProps(const char *_feature, const char *_pkgConfig = nullptr, SDLVersion _sdlVersion = kSDLVersionAny) :
Library({_feature, _pkgConfig, _sdlVersion, nullptr}) {}
LibraryProps &LibrariesVar(const char *var) { librariesVar = var; return *this; }
LibraryProps &Libraries(const char *libs) { libraries = libs; return *this; }
};
const Library *getLibraryFromFeature(const char *feature, bool useSDL2) const;
void writeWarnings(std::ofstream &output) const;