[CMake] SET_TARGET_PROPERTIES DEFINE_SYMBOL

Brad King brad.king at kitware.com
Tue Oct 4 10:04:15 EDT 2005


Patrick Brannan wrote:
> ADD_EXECUTABLE(hello hello.c)
> # ADD_DEFINITIONS(-D_WORLD_) # This works if uncommented
> SET_TARGET_PROPERTIES(hello PROPERTIES DEFINE_SYMBOL _WORLD_)
> =================================
> 
> The ADD_DEFINITIONS command works as expected. SET_TARGET_PROPERTIES 
> does not. I'm sure I'm doing something dumb, but I can't seem to figure 
> it out. I read an earlier post about the same topic, but none of the 
> issues seem to apply in this case.
> 
> I am worrying about this because I am trying to build a an application 
> with both static and dynamic bindings. And we need to apply different 
> definitions to the same sources to get both to build.

CMake will define <libname>_EXPORTS for source files being built for a 
shared library.  This can be used to setup dllexport/dllimport macros in 
the source.  The DEFINE_SYMBOL target property can be used to change the 
name of the symbol defined, so the symbol given is only defined for 
sources built in shared libraries.  It seems the documentation of the 
SET_TARGET_PROPERTIES command does not make this clear.  Please report 
this missing documentation as a bug:

http://www.cmake.org/Bug

Thanks,
-Brad


More information about the CMake mailing list