[CMake] GENERATE_EXPORT_HEADER

Micha Renner Micha.Renner at t-online.de
Thu Sep 6 04:55:40 EDT 2012


Am Mittwoch, den 05.09.2012, 17:27 +0200 schrieb Sergiu Dotenco:
> On 9/5/2012 3:52 PM, Micha Renner wrote:
> > For static libraries the macro GENERATE_EXPORT_HEADER produce an output
> > like this one:
> > 
> > ...
> > #else
> > #  ifndef CTEST_EXPORT
> > #    ifdef cTest_EXPORTS
> >         /* We are building this library */
> > #      define CTEST_EXPORT 
> > #    else
> >         /* We are using this library */
> > #      define CTEST_EXPORT 
> > #    endif
> > #  endif
> > ...
> > 
> > For for a static version of a library CTEST_EXPORT is empty.
> > 
> > For Windows and the MSVC it is not always a good idea, since the MSVC
> > can produce errors in this case.
> 
> What kind of errors? Are you sure that you're using the export macro
> correctly?

In the appendix there is a project that illustrates the problem of the
MSVC.
The example is taken from the ffi library 3.0.11 (types.c/ffi.h).

- unpack the zip file
- build the project
- run the program. If the result is 0 then there is a problem
- edit ctest_export.h.
	- change  #define CTEST_EXPORT in the 
		/* We are using this library */ part
	  to
		#define CTEST_EXPORT extern
- build the project
- run the program. If the result not 0 then the problem is solved.

Greetings

Micha


> 
> > So I propose (static versions of libraries): For the MSVC and Windows
> > CTEST_EXPORT should be defined with "extern", either by option or by
> > default.
> 
> Applying extern to a class definition doesn't make any sense.
> --
> 
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

-------------- next part --------------
A non-text attachment was scrubbed...
Name: t2.zip
Type: application/zip
Size: 2040 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120906/a6e28506/attachment.zip>


More information about the CMake mailing list