<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<font face="Helvetica, Arial, sans-serif">Hi cmake users:<br>
<br>
</font><font face="Helvetica, Arial, sans-serif">I am trying to use
cmake to define a symbol so that I can use the #if syntax in C++.<br>
<br>
I have read the documentation for the </font><font
 face="Helvetica, Arial, sans-serif">SET_TARGET_PROPERTIES command and
it seems to me that there is a property called </font><font
 face="Helvetica, Arial, sans-serif">DEFINE_SYMBOL which sets "... <i>a
symbol that is defined when compiling C or C++ sources</i>"
(<a class="moz-txt-link-freetext"
 href="http://www.cmake.org/HTML/Documentation.html">http://www.cmake.org/HTML/Documentation.html</a>).
However, when I use
this property it does <b>not </b>define the symbol. I am using CMake
v2.2.3 with Microsoft Visual Studio 7 .NET 2003 on a Win32 machine. <br>
<br>
FYI I can get the LINK_FLAGS property to work, but not the
DEFINE_SYMBOL... <br>
<br>
Have I misunderstood something? Am I setting the property correctly?
Any help would be appreciated. My cmake file and source is below:<br>
<br>
<small><font face="Courier New, Courier, monospace"><font
 color="#999999">Start CMakeLists.txt
====================================================</font><br>
# Add Project<br>
PROJECT(TestMain)<br>
<br>
# Setup output paths<br>
SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single
output directory for building all libraries." FORCE)<br>
SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single
output directory for building all executables." FORCE)<br>
<br>
# Add Executable<br>
ADD_EXECUTABLE(TestMain TestMain.cxx)<br>
<b>SET_TARGET_PROPERTIES(TestMain PROPERTIES DEFINE_SYMBOL "MY_SYMBOL")</b><br>
</font></small></font><font face="Helvetica, Arial, sans-serif"><small><font
 face="Courier New, Courier, monospace">TARGET_LINK_LIBRARIES(TestMain
TestMain)</font></small></font><br>
<font face="Helvetica, Arial, sans-serif"><font color="#999999"><small><font
 face="Courier New, Courier, monospace">End CMakeLists.txt
====================================================</font></small></font><br>
<br>
</font><font face="Helvetica, Arial, sans-serif"><small><font
 face="Courier New, Courier, monospace"><font color="#999999">Start
TestMain.cxx ====================================================</font><br>
</font></small></font><font face="Courier New, Courier, monospace">#include
&lt;iostream&gt;<br>
<br>
int main(int argc, char * argv[])<br>
{<br>
&nbsp;&nbsp;&nbsp; #if (MY_SYMBOL)<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "MY_SYMBOL was defined." &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp; #else<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; std::cout &lt;&lt; "MY_SYMBOL was NOT defined." &lt;&lt;
std::endl;<br>
&nbsp;&nbsp;&nbsp; #endif<br>
}</font><br>
<font face="Helvetica, Arial, sans-serif"><font color="#999999"><small><font
 face="Courier New, Courier, monospace">End TestMain.cxx
====================================================</font></small></font></font><br>
<font face="Helvetica, Arial, sans-serif"><br>
NOTE: TestMain.exe prints "MY_SYMBOL was NOT defined."<br>
<br>
Regards, <br>
<br>
Dan [<a class="moz-txt-link-abbreviated"
 href="mailto:d.mueller@qut.edu.au">d.mueller@qut.edu.au</a>]</font><br>
</body>
</html>