[CMake] Re: Help getting -l and -L arguments from apr-config

Bill Hoffman bill.hoffman at kitware.com
Sat May 5 08:52:21 EDT 2007


Matthew Woehlke wrote:
> Trevor Kellaway wrote:
>> Hi,
>>> The following snippet will send the strings "1", "2" and "3" to the 
>>> messages console, each of them on its own line:
>>>
>>>   SET(FOO "1 2 3")
>>>   STRING(REPLACE " " ";" FOO_LIST "${FOO}")
>>>   FOREACH(item ${FOO_LIST})
>>>     MESSAGE(${item})
>>>   ENDFOREACH(item ${FOO_LIST})
>>
>> The "Mastering CMake" book (recommended) also claims you can use this
>> (although I haven't tried it):
>>
>>     SEPARATE_ARGUMENTS(VARIABLE)
>
> Alas, that is no more effective than STRING(REPLACE " " ";" FOO 
> ${FOO}), as Thomas suggested (and which I am currently using)... 
> although, it probably *should* be. 
I think you are going to have to use regular expressions.  You can look 
at the new pkgconfig stuff in CVS CMake:

http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/FindPkgConfig.cmake?rev=1.3&root=CMake&view=auto
It does something like this:

   _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES           "(^| )-l" --libs-only-l )
      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS        "(^| )-L" --libs-only-L )
      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS             ""        --libs )
      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER       ""        --libs-only-other )

      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS        "(^| )-I" --cflags-only-I )
      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )


-Bill




More information about the CMake mailing list