[CMake] Re: Target flags depending on compilation of another target

Rodolfo Lima rodolfo at rodsoft.org
Fri Dec 21 07:14:54 EST 2007


Jesper Eskilson escreveu:

> Not generally, no. However, if you know that you'll be using Make with a
> bourne-shell to build you can sneak in things like "`cat somefile.txt`"
> into your CMAKE_CXX_FLAGS, and have your custom target write flags to
> "somefile.txt". This technique is commonly used in Unix makefiles to
> allow compiler-flags to be generated "on-the-fly" by a utility program.

Wow, that's what McGyver would do if he were a programmer. Thank you!
With Visual C I think I can write a 'here document' and add with
@flags.txt, isn't it?

Is there any way to make cmake support things like this? A common use
case would be like... one of your targets is a custom target which
compiles wxWidgets (for instance). When it gets installed, it creates a
bash script (wx-config) which, when run, returns proper compiler and
linker flags. Those flags are used by another target that has wxWidgets
as dependency.

Regards,
rod



More information about the CMake mailing list