From 7155f143103dbeb86a90c5c8de6e4743b50041fb Mon Sep 17 00:00:00 2001 From: Bastien Bouclet Date: Thu, 15 Sep 2016 09:42:07 +0200 Subject: CREATE_PROJECT: Use SDL_Net2 when building with SDL2 for cmake --- devtools/create_project/cmake.cpp | 50 +++++++++++++++++++++------------------ devtools/create_project/cmake.h | 11 +++++++-- 2 files changed, 36 insertions(+), 25 deletions(-) (limited to 'devtools/create_project') diff --git a/devtools/create_project/cmake.cpp b/devtools/create_project/cmake.cpp index fad9a28367..541e79efab 100644 --- a/devtools/create_project/cmake.cpp +++ b/devtools/create_project/cmake.cpp @@ -34,27 +34,31 @@ CMakeProvider::CMakeProvider(StringList &global_warnings, std::mapenable || featureExcluded(i->name)) continue; - writeFeatureLibSearch(workspace, i->name); + writeFeatureLibSearch(setup, workspace, i->name); workspace << "add_definitions(-D" << i->define << ")\n"; } workspace << "\n"; @@ -99,8 +103,8 @@ void CMakeProvider::createWorkspace(const BuildSetup &setup) { writeGeneratePluginsTable(workspace); } -void CMakeProvider::writeFeatureLibSearch(std::ofstream &workspace, const char *feature) const { - const Library *library = getLibraryFromFeature(feature); +void CMakeProvider::writeFeatureLibSearch(const BuildSetup &setup, std::ofstream &workspace, const char *feature) const { + const Library *library = getLibraryFromFeature(feature, setup.useSDL2); if (library) { if (library->module) { workspace << "Include(" << library->module << ")\n"; @@ -194,13 +198,13 @@ void CMakeProvider::createProjectFile(const std::string &name, const std::string project << "# Libraries\n"; if (name == setup.projectName) { - const Library *sdlLibrary = getLibraryFromFeature(setup.useSDL2 ? "sdl2" : "sdl"); + const Library *sdlLibrary = getLibraryFromFeature("sdl", setup.useSDL2); project << "target_link_libraries(" << name << " ${" << sdlLibrary->librariesVar << "})\n"; for (FeatureList::const_iterator i = setup.features.begin(), end = setup.features.end(); i != end; ++i) { if (!i->enable || featureExcluded(i->name)) continue; - const Library *library = getLibraryFromFeature(i->name); + const Library *library = getLibraryFromFeature(i->name, setup.useSDL2); if (!library) continue; if (library->librariesVar) { diff --git a/devtools/create_project/cmake.h b/devtools/create_project/cmake.h index ec7ff565c9..4d8663e689 100644 --- a/devtools/create_project/cmake.h +++ b/devtools/create_project/cmake.h @@ -53,11 +53,18 @@ protected: const char *getProjectExtension(); private: + enum SDLVersion { + kSDLVersionAny, + kSDLVersion1, + kSDLVersion2 + }; + /** * CMake properties for a library required by a feature */ struct Library { const char *feature; + SDLVersion sdlVersion; const char *module; const char *package; const char *includesVar; @@ -65,7 +72,7 @@ private: const char *libraries; }; - const Library *getLibraryFromFeature(const char *feature) const; + const Library *getLibraryFromFeature(const char *feature, bool useSDL2) const; void writeWarnings(std::ofstream &output) const; void writeDefines(const BuildSetup &setup, std::ofstream &output) const; @@ -75,7 +82,7 @@ private: void writeGeneratePluginsTable(std::ofstream &workspace) const; void writeEnginesLibrariesHandling(const BuildSetup &setup, std::ofstream &workspace) const; void writeEngineDefinitions(std::ofstream &workspace) const; - void writeFeatureLibSearch(std::ofstream &workspace, const char *feature) const; + void writeFeatureLibSearch(const BuildSetup &setup, std::ofstream &workspace, const char *feature) const; bool featureExcluded(const char *name) const; const EngineDesc &findEngineDesc(const std::string &name, const EngineDescList &engines) const; }; -- cgit v1.2.3