From 45dde26fc525ac944547dbe940ab4da581e231dc Mon Sep 17 00:00:00 2001 From: Orgad Shaneh Date: Fri, 10 Mar 2023 10:47:29 +0200 Subject: [PATCH] CREATE_PROJECT: Simplify feature libraries initialization --- devtools/create_project/cmake.cpp | 26 +++++++++++++------------- devtools/create_project/cmake.h | 7 +++++++ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/devtools/create_project/cmake.cpp b/devtools/create_project/cmake.cpp index 5907d3445d1..d5cbb78f7e0 100644 --- a/devtools/create_project/cmake.cpp +++ b/devtools/create_project/cmake.cpp @@ -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++) { diff --git a/devtools/create_project/cmake.h b/devtools/create_project/cmake.h index 520c521202d..37859072fac 100644 --- a/devtools/create_project/cmake.h +++ b/devtools/create_project/cmake.h @@ -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;