[CMake] How to prevent semicolons in pkg-config.pc files generated with configure_file?

Rolf Eike Beer eike at sf-mail.de
Fri Jun 28 13:06:14 EDT 2013


Claus Klein wrote:
> Hi
> 
> I want to create a pkg-config.pc file with cmake.
> 
> claus-kleins-macbook-pro:build clausklein$ pkg-config --libs QtOpenGL
> -L/opt/local/lib -lQtOpenGL -lQtGui -lQtCore
> 
> claus-kleins-macbook-pro:build clausklein$ cmake --version
> cmake version 2.8.10.2
> 
> 
> This are my input values:
> ## message(EXTRA_LIBS=${EXTRA_LIBS})   #
> EXTRA_LIBS=/usr/lib/libpthread.dylib/usr/lib/libcrypto.dylib ##
> message(EXTRA_LIBS="${EXTRA_LIBS}") #
> EXTRA_LIBS=/usr/lib/libpthread.dylib;/usr/lib/libcrypto.dylib
> 
> And this is a sniped of my CMakeLists.txt file:
> 
> # create LIBS and LDFLAGS list
> foreach(_lib ${EXTRA_LIBS})
>     get_filename_component(_lib_name ${_lib} NAME_WE)
>     string(REGEX REPLACE "^lib" "" _name ${_lib_name})
>     list(APPEND LIBS "-l${_name} ")
>     get_filename_component(_lib_dir ${_lib} PATH)
>     list(APPEND LINKFLAGS "-L${_lib_dir} ")
> endforeach()
> list(REMOVE_DUPLICATES LIBS )
> list(REMOVE_DUPLICATES LINKFLAGS )
> 
> # trace
> message( STATUS SNMP_PP_LIBS="${LIBS}")
> message( STATUS SNMP_PP_LDFLAGS="${LINKFLAGS}")
> #
> # -- SNMP_PP_LIBS="-lpthread -lcrypto "
> # -- SNMP_PP_LDFLAGS="-L/usr/lib "
> # ...
> ## configure_file(snmp++-3.pc.in snmp++-3.pc @ONLY)
> # -- Generating snmp++-3.pc file for pkg-config ...
> #
> # Libs.private: @LIBS@ @LINKFLAGS@
> # ... expands to:
> # Libs.private: -lpthread ;-lcrypto  -L/usr/lib
> #                                    ^
> #                 How can I prevent this?

string(REPLACE ";" " " LIBS "${LIBS}")

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130628/7beda2fa/attachment.pgp>


More information about the CMake mailing list