[CMake] Building shared libs on visual
Julien Michel
julien.michel at c-s.cnes.fr
Wed Sep 24 10:13:53 EDT 2008
dear Michael,
I was expecting something like that but as I am not very familiar with
building libraries on windows, I was not sure wether I was right or
wrong. Thank you very much,
Best regards,
Julien
Michael Jackson a écrit :
> Julien,
> Funny. I wrote that wiki entry and it was a bit different when I first
> wrote it but after some feedback I changed the code slightly and
> looking back at the code I don't think it would work correctly for the
> static case.
> Like Werner I actually use a second definition in my code:
> #if defined (_WIN32) && defined (BUILT_AS_DYNAMIC_LIB)
> #if defined(MyLibrary_EXPORTS)
> #define MYLIB_EXPORT __declspec(dllexport)
> #else
> #define MYLIB_EXPORT __declspec(dllimport)
> #endif /* MyLibrary_EXPORTS */
> #else /* defined (_WIN32) */
> #define MYLIB_EXPORT
> #endif
> #endif /* _MyLibrary_DLLDEFINES_H_ */
>
> Then in the cmake code you do something like:
> # Allow the developer to select if Dynamic or Static libraries are built
> OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
> # Set the LIB_TYPE variable to STATIC
> SET (LIB_TYPE STATIC)
> IF (BUILD_SHARED_LIBS)
> # User wants to build Dynamic Libraries, so change the LIB_TYPE
> variable to CMake keyword 'SHARED'
> ADD_DEFINITIONS(-DBUILD_AS_DYNAMIC_LIBRARY)
> SET (LIB_TYPE SHARED)
> ENDIF (BUILD_SHARED_LIBS)
>
> Which should help take care of that case for you.
>
> Mike
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Julien MICHEL - Ingénieur d'études - Traitement d'images
CS Systèmes d'Information - Division ESPACE
Département Information Géographique & Image
Téléphone : +33 561 17 64 27
Email : julien.michel at c-s.fr
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
More information about the CMake
mailing list