[CMake] SET_TARGET_PROPERTIES funny..
Brad King
brad.king at kitware.com
Fri Aug 18 11:52:32 EDT 2006
Thomas Hunger wrote:
> Hi,
> When I do this to SET_TARGET_PROPERTIES:
>
> SET_TARGET_PROPERTIES(extree PROPERTIES
> COMPILE_FLAGS "\n")
>
> make (not cmake) will complain:
>
> CMakeFiles/XXX/build.make:61: *** missing separator. Stop.
>
> This is not out of thin air. I made a different PKGCONFIG macro which
> fits my needs better:
>
> FIND_PROGRAM(PKGCONFIG_EXECUTABLE NAMES pkg-config
> PATHS /usr/local/bin )
>
> MACRO(PKGCONFIG _target _package)
> EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE}
> ARGS ${_package} --libs
> OUTPUT_VARIABLE _libs)
> EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE}
> ARGS ${_package} --cflags
> OUTPUT_VARIABLE _cflags)
> SET_TARGET_PROPERTIES(${_target} PROPERTIES
> LINK_FLAGS ${_libs}
> COMPILE_FLAGS ${_cflags})
> ENDMACRO(PKGCONFIG)
>
> Now sqlite3 provides a sqlite3.pc file with an cflags field of "\n".
> Which is used by SET_TARGET_PROPERTIES. I could catch that error in
> my macro, but I think it would be better to catch it in
> SET_TARGET_PROPERTIES. What do you think?
The COMPILE_FLAGS property is meant for passing low-level
platform-specific flags to the compiler. This is why it uses the
general-purpose property interface. SET_TARGET_PROPERTIES should not
try to interpret the value of any property.
Extracting information from pkg-config is just another way of doing a
library find operation. Commands like EXEC_PROGRAM are meant for such
low-level operations. You can use the STRING command to fix values
before passing them to COMPILE_FLAGS.
-Brad
More information about the CMake
mailing list