[CMake] Simple question
Brad King
brad.king at kitware.com
Tue Jan 25 07:49:14 EST 2005
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