cmake and pkg-config are not good friends at all



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi

I'm writting a FindGTK+.cmake module which should set the CFLAGS and LDFLAGS requiered by GTK+ using pkg-config.

I have:
...
IF(NOT __FIND_GTK_FOUND)
        MESSAGE( "-- GTK+ version ${__FIND_GTK_VERSION_FOUND} found" )
        SET(FIND_GTK_FOUND TRUE)

        EXECUTE_PROCESS(COMMAND
            ${__FIND_GTK_PKG_CONFIG} --cflags ${__FIND_GTK_STRING}
            COMMAND xargs printf %s\
            OUTPUT_VARIABLE FIND_GTK_CFLAGS
        )

        EXECUTE_PROCESS(COMMAND
            ${__FIND_GTK_PKG_CONFIG} --libs ${__FIND_GTK_STRING}
            COMMAND xargs printf %s\
            OUTPUT_VARIABLE FIND_GTK_LDFLAGS
        )

    ENDIF(NOT __FIND_GTK_FOUND)

where __FIND_GTK_FOUND is the the exit status of pkg-config --atleast-version=... --modversion gtk+[-2.0]

The problem is the EXECUTE_PROCESS. If I only write
EXECUTE_PROCESS(COMMAND
   ${__FIND_GTK_PKG_CONFIG} --cflags ${__FIND_GTK_STRING}
   OUTPUT_VARIABLE FIND_GTK_CFLAGS
)

then FIND_GTK_CFLAGS will have a new-line (\n) character at the end of the string. This is a problem since
SET_SOURCE_FILES_PROPERTIES(containers.c COMPILE_FLAGS ${FIND_GTK_CFLAGS}) leads to an incorrect Makefile. Why on earth
is there a new-line character after all and how can I get rid of it?

EXECUTE_PROCESS(COMMAND
   ${__FIND_GTK_PKG_CONFIG} --cflags ${__FIND_GTK_STRING}
   COMMAND sed -n 1p

doesn't work, I don't know why, I still get two lines. The only way I could get rid of the new-line is with the
"xargs printf %s\ " command, but I don't like this very much.

How can I solve this problem? Is this pkg-config problem after all?

Regards
Pablo


- --
Pablo Yánez Trujillo
http://klingsor.informatik.uni-freiburg.de/
My public key: http://klingsor.informatik.uni-freiburg.de/gpg/supertux.asc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkj+eNMACgkQDzf8xo+0xRU5hwCePl5y5rWU5dvKz7UTl1AqsX1l
NRsAn27TH7UDFlUxM3W4fNE8yRGPiexK
=B7Sd
-----END PGP SIGNATURE-----


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]