Fixed bug 4144 - CMake complains about trailing spaces in sdl2.pc Azamat H. Hackimov When you try use SDL2 2.0.8 in CMake project in Linux, it complains about trailing spaces in sdl2.pc: CMake Error at CMakeLists.txt:147 (add_executable): Target "TestSimpleMain" links to item "-L/usr/lib64 -lSDL2 " which has leading or trailing whitespace. This is now an error according to policy CMP0004.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
diff --git a/configure b/configure
index e932dce..d8fc074 100755
--- a/configure
+++ b/configure
@@ -15752,10 +15752,17 @@ EXTRA_LDFLAGS="$BASE_LDFLAGS"
# fi
#done
SDL_CFLAGS="$BASE_CFLAGS"
-SDL_LIBS="-lSDL2 $BASE_LDFLAGS"
-CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
-CFLAGS="$CFLAGS $EXTRA_CFLAGS"
-LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+SDL_LIBS="-lSDL2"
+if "$BASE_LDFLAGS" != "" ; then
+ SDL_LIBS="$SDL_LIBS $BASE_LDFLAGS"
+fi
+if "$EXTRA_CFLAGS" != "" ; then
+ CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
+ CFLAGS="$CFLAGS $EXTRA_CFLAGS"
+fi
+if "$EXTRA_LDFLAGS" != "" ; then
+ LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+fi
base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
diff --git a/configure.in b/configure.in
index 9d815db..1b9935c 100644
--- a/configure.in
+++ b/configure.in
@@ -123,10 +123,17 @@ EXTRA_LDFLAGS="$BASE_LDFLAGS"
# fi
#done
SDL_CFLAGS="$BASE_CFLAGS"
-SDL_LIBS="-lSDL2 $BASE_LDFLAGS"
-CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
-CFLAGS="$CFLAGS $EXTRA_CFLAGS"
-LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+SDL_LIBS="-lSDL2"
+if [ "$BASE_LDFLAGS" != "" ]; then
+ SDL_LIBS="$SDL_LIBS $BASE_LDFLAGS"
+fi
+if [ "$EXTRA_CFLAGS" != "" ]; then
+ CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
+ CFLAGS="$CFLAGS $EXTRA_CFLAGS"
+fi
+if [ "$EXTRA_LDFLAGS" != "" ]; then
+ LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
+fi
dnl set this to use on systems that use lib64 instead of lib
base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`