[CMake] trying to modify preprocessor statements on same source file (probs with SET_SOURCE_FILES_PROPERTIES & ADD_DEFINITIONS)

Philip Lowman philip at yhbt.com
Tue Mar 20 20:58:23 EST 2007


Philip Lowman wrote:
> I'm trying to facilitate compiling the same source file once with a
> STATIC_BUILD preprocessor statement defined to 1 and once with it
> defined to 0.  I can't seem to figure out a way to do this, however.

Nevermind, I found a way to do this using the COMPILE_FLAGS option to
SET_TARGET_PROPERTIES.  I'm not sure if my problem constitutes a bug or
not but it sure is unexpected behavior (and I've been using CMake on and
off for 4-5 months now).  Luckily it's a problem others have had
problems with before so I found a solution on the mailing list.

Would someone who has commit access modify the documentation to make
note of the limitation of ADD_DEFINITIONS and
SET_SOURCE_FILES_PROPERTIES?  Most of the other CMake commands I have
come across (like SET_TARGET_PROPERTIES) always seem to be run in the
context of where they are in the script.

Based on my testing it's perfectly legal to modify source file
properties after you call ADD_EXECUTABLE()..  This seems somewhat
backwards... kind of like specifying an INSTALL() target before you've
specified a target.

-- 
Philip Lowman
Simulation Development Engineer, Modeling and Simulation Technology
General Dynamics Land Systems
http://www.gdls.com


More information about the CMake mailing list