[CMake] Re: A few newbie "how to" questions

Matthew Woehlke mw_triad at users.sourceforge.net
Fri Mar 9 15:30:24 EST 2007


Simon Perreault wrote:
> 2. Is it possible to have per-sourcefile definitions? i.e. In one directory I 
> have a few .c files which require the MATLAB_MEX_FILE definition while others 
> are stand-alone programs that don't need it. ADD_DEFINITIONS seems to have a 
> global effect.

Hey, I can answer that! :-) (I'm just learning myself...)

I actually had to do this for my own project. You can use:

SET_SOURCE_FILES_PROPERTIES(<file> PROPERTIES COMPILE_FLAGS <flags>)

...replacing <file> and <flags>, of course. Be sure to put <flags> in 
quotes if there are spaces.

> 3. Same question as 2 but concerning INCLUDE_DIRECTORIES.

Hmm... I *think* '-I' works on MSVC, so you could just use the flags 
'-I<path>'. Or investigate if there is a corresponding property (I don't 
know if there is or is not).

> 4 and 5. Same questions as 2 and 3, but this time I want per-library or 
> per-executable instead of per-sourcefile.

I think SET_TARGET_PROPERTIES is what you want, but I haven't used it.

-- 
Matthew
You are in a meadow. A huge red dragon stands before you.
 > FIGHT DRAGON
With what? You don't have any weapons.
 > RUN AWAY
You wisely exercise the better part of valor.



More information about the CMake mailing list