aboutsummaryrefslogtreecommitdiff
path: root/devtools
diff options
context:
space:
mode:
authorBastien Bouclet2018-04-22 09:18:04 +0200
committerBastien Bouclet2018-04-22 09:27:04 +0200
commit04c321d200e10b60b04d1a5a07dc3936f3d29806 (patch)
tree01e896e50db34f2350765999f6e7c73cad3958b8 /devtools
parent086ab443c015274a2aceca3ef5c943ebd3aff792 (diff)
downloadscummvm-rg350-04c321d200e10b60b04d1a5a07dc3936f3d29806.tar.gz
scummvm-rg350-04c321d200e10b60b04d1a5a07dc3936f3d29806.tar.bz2
scummvm-rg350-04c321d200e10b60b04d1a5a07dc3936f3d29806.zip
CREATE_PROJECT: CMAKE: Fix importing SDL2 when it was built using CMake
When SDL is built using CMake, Find_Package imports a target instead of defining variables. If a target was imported we now define the include path and linker flags variables from the target's properties. Using imported targets is a best practice. Ideally, we should define an imported target when we detect variables were defined. However, the linker flags variable would need to be parsed into a library path and a list of libraries, making that approach impractical.
Diffstat (limited to 'devtools')
-rw-r--r--devtools/create_project/cmake.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/devtools/create_project/cmake.cpp b/devtools/create_project/cmake.cpp
index 2c4553a6c6..d1a2be86cc 100644
--- a/devtools/create_project/cmake.cpp
+++ b/devtools/create_project/cmake.cpp
@@ -37,7 +37,7 @@ CMakeProvider::CMakeProvider(StringList &global_warnings, std::map<std::string,
const CMakeProvider::Library *CMakeProvider::getLibraryFromFeature(const char *feature, bool useSDL2) const {
static const Library s_libraries[] = {
{ "sdl", kSDLVersion1, "FindSDL", "SDL", "SDL_INCLUDE_DIR", "SDL_LIBRARY", 0 },
- { "sdl", kSDLVersion2, 0, "SDL2", "SDL2_INCLUDE_DIRS", "SDL2_LIBRARIES", 0 },
+ { "sdl", kSDLVersion2, 0, "SDL2", 0, "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 },
@@ -84,8 +84,17 @@ void CMakeProvider::createWorkspace(const BuildSetup &setup) {
workspace << "include_directories(${" << setup.projectDescription << "_SOURCE_DIR} ${" << setup.projectDescription << "_SOURCE_DIR}/engines "
"$ENV{"<<LIBS_DEFINE<<"}/include .)\n\n";
- workspace << "# Libraries and features\n";
+ workspace << "# Libraries and features\n\n";
writeFeatureLibSearch(setup, workspace, "sdl");
+
+ workspace << "# Depending on how SDL2 was built, there can be either and imported target or flags variables\n";
+ workspace << "# Define the flags variables from the imported target if necessary\n";
+ workspace << "if (TARGET SDL2::SDL2)\n";
+ workspace << " get_target_property(SDL2_INCLUDE_DIRS SDL2::SDL2 INTERFACE_INCLUDE_DIRECTORIES)\n";
+ workspace << " get_target_property(SDL2_LIBRARIES SDL2::SDL2 LOCATION)\n";
+ workspace << "endif()\n";
+ workspace << "include_directories(${SDL2_INCLUDE_DIRS})\n\n";
+
for (FeatureList::const_iterator i = setup.features.begin(), end = setup.features.end(); i != end; ++i) {
if (!i->enable || featureExcluded(i->name)) continue;