Fixed bug 4144 - CMake complains about trailing spaces in sdl2.pc
authorSam Lantinga <slouken@libsdl.org>
Mon, 23 Apr 2018 21:55:59 -0700
changeset 1195128be2719184c
parent 11950 2a7839691e3d
child 11952 d82e6e63c632
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.
configure
configure.in
     1.1 --- a/configure	Mon Apr 23 21:50:03 2018 -0700
     1.2 +++ b/configure	Mon Apr 23 21:55:59 2018 -0700
     1.3 @@ -15752,10 +15752,17 @@
     1.4  #    fi
     1.5  #done
     1.6  SDL_CFLAGS="$BASE_CFLAGS"
     1.7 -SDL_LIBS="-lSDL2 $BASE_LDFLAGS"
     1.8 -CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
     1.9 -CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    1.10 -LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    1.11 +SDL_LIBS="-lSDL2"
    1.12 +if  "$BASE_LDFLAGS" != "" ; then
    1.13 +    SDL_LIBS="$SDL_LIBS $BASE_LDFLAGS"
    1.14 +fi
    1.15 +if  "$EXTRA_CFLAGS" != "" ; then
    1.16 +    CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
    1.17 +    CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    1.18 +fi
    1.19 +if  "$EXTRA_LDFLAGS" != "" ; then
    1.20 +    LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    1.21 +fi
    1.22  
    1.23  base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
    1.24  
     2.1 --- a/configure.in	Mon Apr 23 21:50:03 2018 -0700
     2.2 +++ b/configure.in	Mon Apr 23 21:55:59 2018 -0700
     2.3 @@ -123,10 +123,17 @@
     2.4  #    fi
     2.5  #done
     2.6  SDL_CFLAGS="$BASE_CFLAGS"
     2.7 -SDL_LIBS="-lSDL2 $BASE_LDFLAGS"
     2.8 -CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
     2.9 -CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    2.10 -LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    2.11 +SDL_LIBS="-lSDL2"
    2.12 +if [ "$BASE_LDFLAGS" != "" ]; then
    2.13 +    SDL_LIBS="$SDL_LIBS $BASE_LDFLAGS"
    2.14 +fi
    2.15 +if [ "$EXTRA_CFLAGS" != "" ]; then
    2.16 +    CPPFLAGS="$CPPFLAGS $EXTRA_CFLAGS"
    2.17 +    CFLAGS="$CFLAGS $EXTRA_CFLAGS"
    2.18 +fi
    2.19 +if [ "$EXTRA_LDFLAGS" != "" ]; then
    2.20 +    LDFLAGS="$LDFLAGS $EXTRA_LDFLAGS"
    2.21 +fi
    2.22  
    2.23  dnl set this to use on systems that use lib64 instead of lib
    2.24  base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`