aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorBastien Bouclet2016-09-15 09:42:07 +0200
committerBastien Bouclet2016-09-15 12:44:57 +0200
commit7155f143103dbeb86a90c5c8de6e4743b50041fb (patch)
tree68e2f54d6ea22624955e8906185fa776a0cab0e3 /devtools
parent4c7d3c1857ee282a49c0f500f2ef9ca65e72360c (diff)
downloadscummvm-rg350-7155f143103dbeb86a90c5c8de6e4743b50041fb.tar.gz
scummvm-rg350-7155f143103dbeb86a90c5c8de6e4743b50041fb.tar.bz2
scummvm-rg350-7155f143103dbeb86a90c5c8de6e4743b50041fb.zip
CREATE_PROJECT: Use SDL_Net2 when building with SDL2 for cmake
Diffstat (limited to 'devtools')
-rw-r--r--devtools/create_project/cmake.cpp50
-rw-r--r--devtools/create_project/cmake.h11
2 files changed, 36 insertions, 25 deletions
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::map<std::string,
: ProjectProvider(global_warnings, project_warnings, version) {
}
-const CMakeProvider::Library *CMakeProvider::getLibraryFromFeature(const char *feature) const {
+const CMakeProvider::Library *CMakeProvider::getLibraryFromFeature(const char *feature, bool useSDL2) const {
static const Library s_libraries[] = {
- { "sdl", "FindSDL", "SDL", "SDL_INCLUDE_DIR", "SDL_LIBRARY", 0 },
- { "sdl2", 0, "SDL2", "SDL2_INCLUDE_DIRS", "SDL2_LIBRARIES", 0 },
- { "freetype", "FindFreetype", "Freetype", "FREETYPE_INCLUDE_DIRS", "FREETYPE_LIBRARIES", 0 },
- { "libz", "FindZLIB", "ZLIB", "ZLIB_INCLUDE_DIRS", "ZLIB_LIBRARIES", 0 },
- { "png", "FindPNG", "PNG", "PNG_INCLUDE_DIRS", "PNG_LIBRARIES", 0 },
- { "jpeg", "FindJPEG", "JPEG", "JPEG_INCLUDE_DIRS", "JPEG_LIBRARIES", 0 },
- { "mpeg2", "FindMPEG2", "MPEG2", "MPEG2_INCLUDE_DIRS", "MPEG2_mpeg2_LIBRARY", 0 },
- { "flac", 0, 0, 0, 0, "FLAC" },
- { "mad", 0, 0, 0, 0, "mad" },
- { "vorbis", 0, 0, 0, 0, "vorbisfile vorbis ogg" },
- { "theora", 0, 0, 0, 0, "theoradec" },
- { "fluidsynth",0, 0, 0, 0, "fluidsynth" },
- { "faad", 0, 0, 0, 0, "faad" },
- { "libcurl", "FindCURL", "CURL", "CURL_INCLUDE_DIRS", "CURL_LIBRARIES", 0 },
- { "sdlnet", "FindSDL_net", "SDL_net", "SDL_NET_INCLUDE_DIRS", "SDL_NET_LIBRARIES", 0 }
+ { "sdl", kSDLVersion1, "FindSDL", "SDL", "SDL_INCLUDE_DIR", "SDL_LIBRARY", 0 },
+ { "sdl", kSDLVersion2, 0, "SDL2", "SDL2_INCLUDE_DIRS", "SDL2_LIBRARIES", 0 },
+ { "freetype", kSDLVersionAny, "FindFreetype", "Freetype", "FREETYPE_INCLUDE_DIRS", "FREETYPE_LIBRARIES", 0 },
+ { "libz", kSDLVersionAny, "FindZLIB", "ZLIB", "ZLIB_INCLUDE_DIRS", "ZLIB_LIBRARIES", 0 },
+ { "png", kSDLVersionAny, "FindPNG", "PNG", "PNG_INCLUDE_DIRS", "PNG_LIBRARIES", 0 },
+ { "jpeg", kSDLVersionAny, "FindJPEG", "JPEG", "JPEG_INCLUDE_DIRS", "JPEG_LIBRARIES", 0 },
+ { "mpeg2", kSDLVersionAny, "FindMPEG2", "MPEG2", "MPEG2_INCLUDE_DIRS", "MPEG2_mpeg2_LIBRARY", 0 },
+ { "flac", kSDLVersionAny, 0, 0, 0, 0, "FLAC" },
+ { "mad", kSDLVersionAny, 0, 0, 0, 0, "mad" },
+ { "vorbis", kSDLVersionAny, 0, 0, 0, 0, "vorbisfile vorbis ogg" },
+ { "theora", kSDLVersionAny, 0, 0, 0, 0, "theoradec" },
+ { "fluidsynth",kSDLVersionAny, 0, 0, 0, 0, "fluidsynth" },
+ { "faad", kSDLVersionAny, 0, 0, 0, 0, "faad" },
+ { "libcurl", kSDLVersionAny, "FindCURL", "CURL", "CURL_INCLUDE_DIRS", "CURL_LIBRARIES", 0 },
+ { "sdlnet", kSDLVersion1, "FindSDL_net", "SDL_net", "SDL_NET_INCLUDE_DIRS", "SDL_NET_LIBRARIES", 0 },
+ { "sdlnet", kSDLVersion2, 0, 0, 0, 0, "SDL2_net" }
};
for (unsigned int i = 0; i < sizeof(s_libraries) / sizeof(s_libraries[0]); i++) {
- if (std::strcmp(feature, s_libraries[i].feature) == 0) {
+ bool matchingSDL = (s_libraries[i].sdlVersion == kSDLVersionAny)
+ || (useSDL2 && s_libraries[i].sdlVersion == kSDLVersion2)
+ || (!useSDL2 && s_libraries[i].sdlVersion == kSDLVersion1);
+ if (std::strcmp(feature, s_libraries[i].feature) == 0 && matchingSDL) {
return &s_libraries[i];
}
}
@@ -81,11 +85,11 @@ void CMakeProvider::createWorkspace(const BuildSetup &setup) {
"$ENV{"<<LIBS_DEFINE<<"}/include)\n\n";
workspace << "# Libraries and features\n";
- writeFeatureLibSearch(workspace, setup.useSDL2 ? "sdl2" : "sdl");
+ writeFeatureLibSearch(setup, workspace, "sdl");
for (FeatureList::const_iterator i = setup.features.begin(), end = setup.features.end(); i != end; ++i) {
if (!i->enable || 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;
};