<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Bitstream Vera Sans; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"></span> </div><br><div><div>On Jul 11, 2008, at 11:34 AM, Mehdi Rabah wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Thu, Jul 10, 2008 at 12:43 PM, Yuri Timenkov <<a href="mailto:ytimenkov@parallels.com">ytimenkov@parallels.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> <div class="Ih2E3d"><br> <br> On Monday 07 July 2008 19:59:24 Mehdi Rabah wrote:<br> </div><div><div></div><div class="Wj3C7c">> Hi,<br> ><br> > I need to set multiple symbols in one of my target of my project. I can't<br> > use add_definitions because I don't want to define those variable for all<br> > my targets, so I tried custom properties.<br> ><br> > set_target_properties( target PROPERTIES DEFINE_SYMBOL VALUE1 VALUE2 )<br> > doesn't work : the function doesn't expect this number of variables.<br> ><br> > if I try :<br> ><br> > set( var "VALUE1 VALUE2" ).<br> > set_target_properties( target PROPERTIES DEFINE_SYMBOL ${var} )<br> ><br> > I get<br> ><br> > c1xx : fatal error C1083: 'VALUE2': No such file or directory<br> ><br> > I'm working with the microsoft compiler, and cmake 2.6.<br> </div></div>I just discovered nice feature: COMPILE_DEFINITIONS property.<br> That is you can add custom defines to source files, targets or directories (with<br> commands set_source_files_properties, set_target_properties and<br> set_directory_properties commands accordingly).<br> <br> Moreover, COMPILE_DEFINITIONS can be configuration-specific, like<br> COMPILE_DEFINITIONS_DEBUG.<br> </blockquote><div><br>Thanks,<br><br>I also discovered (in the doc) that cmake automatically define the targetName_EXPORTS when compiling. I didn't tried it yet but it's exactly what I need.<br> <br></div></div></blockquote></div><br><div>Yes, when you are on Windows (MSVC and MINGW at least) AND building a SHARED library, then cmake will add the targetName_EXPORTS when compiling. It is up to you to add the proper code into a header file to make user of that information. An example of this would be:</div><div><br></div><div><div>///////////////////////////////////////////////////////////////////////////////</div><div>//</div><div>// Copyright (c) 2007, mjackson</div><div>// All rights reserved.</div><div>// BSD License: <a href="http://www.opensource.org/licenses/bsd-license.html">http://www.opensource.org/licenses/bsd-license.html</a></div><div>//</div><div>// This code was written under United States Air Force Contract number</div><div>// FA8650-04-C-5229</div><div>//</div><div>///////////////////////////////////////////////////////////////////////////////</div><div>#ifndef _MXA_DLL_EXPORT_H_</div><div>#define _MXA_DLL_EXPORT_H_</div><div><br></div><div>/* Cmake will define MXADataModel_EXPORTS on Windows when it</div><div>configures to build a shared library. If you are going to use</div><div>another build system on windows or create the visual studio</div><div>projects by hand you need to define MXADataModel_EXPORTS when</div><div>building a DLL on windows.</div><div>*/</div><div><br></div><div>#if defined (WIN32) && defined (BUILD_SHARED_LIBS)</div><div>#if defined (_MSC_VER)</div><div>#pragma warning(disable: 4251)</div><div>#endif</div><div> #if defined(MXADataModel_EXPORTS)</div><div> #define MXA_EXPORT __declspec(dllexport)</div><div> #else</div><div> #define MXA_EXPORT __declspec(dllimport)</div><div> #endif /* MXADataModel_EXPORTS */</div><div>#else /* defined (_WIN32) && defined (MXA_BUILD_SHARED_LIBS) */</div><div> #define MXA_EXPORT</div><div>#endif</div><div>#endif /* _MXA_DLL_EXPORT_H_ */</div><div><br></div><div>I also use the following in my CMakeLists.txt code:</div><div><br></div><div><div># Build shared libraries</div><div>OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF)</div><div>SET (LIB_TYPE STATIC)</div><div>SET (MXA_BUILT_AS_DYNAMIC_LIB)</div><div>IF (BUILD_SHARED_LIBS)</div><div> SET (LIB_TYPE SHARED)</div><div> SET (MXA_BUILT_AS_DYNAMIC_LIB 1)</div><div> IF (WIN32)</div><div> ADD_DEFINITIONS("-DBUILD_SHARED_LIBS")</div><div> ENDIF (WIN32)</div><div>ENDIF (BUILD_SHARED_LIBS)</div><div><br></div><div><br></div></div></div></body></html>