[CMake] Problem with SET_TARGET_PROPERTIES DEFINE_SYMBOL property

Filipe Sousa filipe at ipb.pt
Tue Apr 4 05:14:19 EDT 2006


On Tuesday 04 April 2006 06:10, Dan Mueller wrote:
> Hi cmake users:
>
> I am trying to use cmake to define a symbol so that I can use the #if
> syntax in C++.
>
> I have read the documentation for the SET_TARGET_PROPERTIES command and
> it seems to me that there is a property called DEFINE_SYMBOL which sets
> "... /a symbol that is defined when compiling C or C++ sources/"
> (http://www.cmake.org/HTML/Documentation.html). However, when I use this
> property it does *not *define the symbol. I am using CMake v2.2.3 with
> Microsoft Visual Studio 7 .NET 2003 on a Win32 machine.
>
> FYI I can get the LINK_FLAGS property to work, but not the DEFINE_SYMBOL...
>
> Have I misunderstood something? Am I setting the property correctly? Any
> help would be appreciated. My cmake file and source is below:
>
> Start CMakeLists.txt ====================================================
> # Add Project
> PROJECT(TestMain)
>
> # Setup output paths
> SET(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single
> output directory for building all libraries." FORCE)
> SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin CACHE PATH "Single
> output directory for building all executables." FORCE)
>
> # Add Executable
> ADD_EXECUTABLE(TestMain TestMain.cxx)
> *SET_TARGET_PROPERTIES(TestMain PROPERTIES DEFINE_SYMBOL "MY_SYMBOL")*

ADD_DEFINITIONS(-DMY_SYMBOL)

> TARGET_LINK_LIBRARIES(TestMain TestMain)
> End CMakeLists.txt ====================================================
>
> Start TestMain.cxx ====================================================
> #include <iostream>
>
> int main(int argc, char * argv[])
> {
>     #if (MY_SYMBOL)
>         std::cout << "MY_SYMBOL was defined." << std::endl;
>     #else
>         std::cout << "MY_SYMBOL was NOT defined." << std::endl;
>     #endif
> }
> End TestMain.cxx ====================================================
>
> NOTE: TestMain.exe prints "MY_SYMBOL was NOT defined."
>
> Regards,
>
> Dan [d.mueller at qut.edu.au]

fsousa at neptuno ~ $ cmake --help-command ADD_DEFINITIONS
cmake version 2.3-20060330
  ADD_DEFINITIONS
       Adds -D define flags to the command line of C and C++ compilers.

         ADD_DEFINITIONS(-DFOO -DBAR ...)

       Adds flags to command line of C and C++ compilers.  This command can
       be used to add any flag to a compile line, but the -D flag is accepted
       most C/C++ compilers.  Other flags may not be as portable.


-- 
Filipe Sousa
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20060404/0d0b087a/attachment-0001.pgp


More information about the CMake mailing list