[Scummvm-git-logs] scummvm master -> 04c321d200e10b60b04d1a5a07dc3936f3d29806
bgK
bastien.bouclet at gmail.com
Sun Apr 22 09:27:56 CEST 2018
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
04c321d200 CREATE_PROJECT: CMAKE: Fix importing SDL2 when it was built using CMake
Commit: 04c321d200e10b60b04d1a5a07dc3936f3d29806
https://github.com/scummvm/scummvm/commit/04c321d200e10b60b04d1a5a07dc3936f3d29806
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2018-04-22T09:27:04+02:00
Commit Message:
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.
Changed paths:
devtools/create_project/cmake.cpp
diff --git a/devtools/create_project/cmake.cpp b/devtools/create_project/cmake.cpp
index 2c4553a..d1a2be8 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;
More information about the Scummvm-git-logs
mailing list