<div dir="ltr">On Thu, Sep 4, 2008 at 8:24 PM, Christopher Harvey <span dir="ltr">&lt;<a href="mailto:chris@basementcode.com">chris@basementcode.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello list,<br>
<br>
I&#39;ll just start off by pasting my CMakeLists.txt, and I&#39;ll explain the problem right after.<br>
<br>
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)<br>
ADD_LIBRARY(Portal SHARED<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BSPWorld.cc<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Polygon3D.cc)<br>
SET_TARGET_PROPERTIES(Portal PROPERTIES<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COMPILE_FLAGS &quot;-fvisibility=hidden -g&quot;<br>
# &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COMPILE_FLAGS &quot;-O3&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LIBRARY_OUTPUT_DIRECTORY ../bin)<br>
<br>
SET_DIRECTORY_PROPERTIES(PROPERTIES<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;COMPILE_DEFINITIONS &quot;DLLEXPORT=__attribute__ ((visibility(&quot;default&quot;)))&quot;<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#DLLLOCAL=&quot;__attribute__ ((visibility(\&quot;hidden\&quot;)))&quot;)<br>
)<br>
<br>
Basically, I&#39;d like to have DLLEXPORT in the source code replaced with __attribute__ ((visibility(&quot;default&quot;)))<br>
when looking at the verbose output of the unix makefile I see this in the compile command:<br>
<br>
/usr/bin/c++ &nbsp; -D&quot;DLLEXPORT=__attribute__ ((visibility(&quot;</blockquote><div><br>Don&#39;t you need to escape the quotes around &quot;default&quot;?&nbsp; So:<br><br>COMPILE_DEFINITIONS &quot;DLLEXPORT=__attribute__ ((visibility(\&quot;default\&quot;)))&quot;<br>
&nbsp;</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">And the grand goal is to avoid putting this in my code:<br>
<br>
#ifdef _MSC_VER<br>
&nbsp;#ifdef BUILDING_DLL<br>
 &nbsp; #define DLLEXPORT __declspec(dllexport)<br>
&nbsp;#else<br>
 &nbsp; #define DLLEXPORT __declspec(dllimport)<br>
&nbsp;#endif<br>
&nbsp;#define DLLLOCAL<br>
#else<br>
&nbsp;#ifdef HAVE_GCCVISIBILITYPATCH<br>
 &nbsp; #define DLLEXPORT __attribute__ ((visibility(&quot;default&quot;)))<br>
 &nbsp; #define DLLLOCAL __attribute__ ((visibility(&quot;hidden&quot;)))<br>
&nbsp;#else<br>
 &nbsp; #define DLLEXPORT<br>
 &nbsp; #define DLLLOCAL<br>
&nbsp;#endif<br>
</blockquote><div><br>If you want your code to be able to be #included by others it&#39;s probably best to leave the defines in a common file (primarily due to the __declspec(dllimport) declaration).&nbsp; Ultimately you could force the user to define what DLLEXPORT and DLLLOCAL means for every compiler they want to use in their build system but having an include file that does this for you and them may be a bit more convenient.<br>
<br>Also, is HAVE_GCCVISIBILITYPATCH a custom declaration?&nbsp; If so you may be able to rely on __GNUC__ and __GNUC_MINOR__ which could alleviate the need to define this.<br><br><a href="http://predef.sourceforge.net/precomp.html#sec13">http://predef.sourceforge.net/precomp.html#sec13</a><br>
<br>HTH<br></div></div><br>-- <br>Philip Lowman<br>
</div>