[CMake] How to set definitions
Micha Renner
Micha.Renner at t-online.de
Fri Feb 18 07:58:39 EST 2011
ADD_DEFINITION sets the definitions for a compiler without target
binding. This means once it is used all subsequent targets and
subdirectories have these definitions
ADD_DEFINITIONS(-DHAVE_CONFIG_H -DEXCLUDE ALL_PINGUINS)
COMPILE_DEFINITIONS is a property which is used frequently with
SET_TARGET_PROPERTIES. Here the definitions are set for the target only.
SET_TARGET_PROPERTIES(_targetname PROPERTIES
COMPILE_DEFINITIONS "HAVE_CONFIG_H;EXCLUDE_ALL_PINGUINS")
No -D, parameters are separated by ";"
ADD_DEFINITIONS- and SET_TARGET_PROPERTIES can be mixed, depending what
you want.
Here is an nice typical example:
SET(_definitions G_LOG_DOMAIN=\"Gtk\"
GTK_LIBDIR=\"${DGTK_LIBDIR}\"
GTK_DATADIR=\"${GTK_DATADIR}\"
GTK_DATA_PREFIX=\"/${GTK_DATA_PREFIX}\"
GTK_SYSCONFDIR=\"${_sysConfDir}\"
GTK_VERSION=\"${PACKAGE_VERSION}\"
GTK_BINARY_VERSION=\"${GTK_BINARY_VERSION}\"
GTK_PRINT_BACKENDS=\"${GTK_PRINT_BACKENDS}\"
GTK_COMPILATION
GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED)
SET_TARGET_PROPERTIES(${_gtkTarget} PROPERTIES
COMPILE_DEFINITIONS "${_definitions}")
CMAKE_REQUIRED_DEFINITIONS is a variable which belongs to the CheckC
command-family, which is important for CTest (Not sure!). See the
documentation there.
Greetings
Micha
Am Donnerstag, den 17.02.2011, 15:30 -0200 schrieb Felipe Ferreri
Tonello:
> Hello guys,
>
> What's the difference to use add_definitions(...), CMAKE_REQUIRED_DEFINITIONS
> and COMPILE_DEFINITIONS ??
>
> I've read the documentation but I need some examples and simple discription
> how to use it.
This is a contradiction in itself.
> GTK_PRINT_PREVIEW_COMMAND=
> - Felipe
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list