[CMake] Create a project that generate the .dll and the .lib

Brad King brad.king at kitware.com
Fri Aug 25 09:16:18 EDT 2006


alan.prat at bt.com wrote:
> I try to write a CMakeList.txt file which create a DLL project under Visual Studio .NET 2003 by using ADD_LIBRARY.
>  
> How do I make my project to generate both the .dll and the .lib ?

ADD_LIBRARY(mylib SHARED src1.cxx src2.cxx ...)

Make sure the source files use __declspec(dllexport) tags.  You can test
for the definition mylib_EXPORTS in the preprocessor to switch between
__declspec(dllexport) and __declspec(dllimport) appropriately in header
files.  Alternatively you can use a .def file by adding it as a source file.

-Brad


More information about the CMake mailing list