[CMake] Simple question

Luca Cappa luca.cappa at i-medlab.com
Thu Jan 27 06:02:01 EST 2005


Hello Brad,

you helped me greatly, thanks. Now the only very little problem I had 
encountered is that I was getting a warning by the distcc compiler (im 
using distribuited compilation since im running on a pII400Mhz). The 
warning is due to the fact that the variable CMAKE_CXX_FLAGS contains 
some "-lXXXX" flags, which when passed as argumetns to the "distcc -c" 
command they issue a warning saying that those arguments were ignored 
since linking has not been done (and it's right :) ).

I simply resolved the problem by putting the ouput of "pkg-config 
--cflags gtkmm" in the CMAKE_CXX_FLAGS
and the output of "pkg-config --libs gtkmm" in the 
CMAKE_EXE_LINKER_FLAGS variable. I found the CMAKE_EXE_LINKER_FLAGS 
variable by searching directly in the CMake source code. My question is:
is it safe to do what i did? Is there any reason to not use those 
variables? Which would be the formal way of setting the cflags and the 
libs thru the use of pkg-config?

Greetings,
Luca

Brad King wrote:

> Luca Cappa wrote:
>
>> Well, i would like also to know if it is possible to set the value of 
>> a variable to the output of a command, i.e. how to put the output of 
>> "pkg-config --cflags --libs gtkmm" in the variable directly.
>>
>>> Is this the right way to add some values to a variable?
>>>
>>> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} `pkg-config --cflags --libs 
>>> gtkmm`")
>>
>
> Use the EXEC_PROGRAM command and then use the CACHE option of the SET 
> command to save the output to a variable like GTK_PKG_FLAGS.  Then use 
> the SET command to add the value.  Something like this:
>
> IF(NOT GTK_PKG_FLAGS)
>   EXEC_PROGRAM(pkg-config ARGS --cflags --libs gtkmm
>                OUTPUT_VARIABLE GTK_PKG_FLAGS)
>   SET(GTK_PKG_FLAGS "${GTK_PKG_FLAGS}" CACHE STRING "GTK Flags")
> ENDIF(NOT GTK_PKG_FLAGS)
> SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GTK_PKG_FLAGS}")
>
> -Brad
>



More information about the CMake mailing list