[CMake] Cmake and Win32 plugin linking issues.

William A. Hoffman billlist at nycap.rr.com
Sun Aug 20 11:10:39 EDT 2006


At 09:53 AM 8/20/2006, Jamie Jones wrote:
>G'day List,
>
>I've been happily cmakifing my opensource project and after a good
>success on *NIX (Yay! no more autotools) have run into a snag.
>
>We use a plugin system where our main binary loads a plugin eg an opengl
>renderer. On *NIX this is fine because you can have undefined symbols
>when you link, and on OSX I can pass some flags to gcc to achieve the
>same effect. Windows on the other hand has a whinge and refuses to link.
>
>As a result, I've been unable to switch from a hand crafted .bat file to
>useing cmake on Win32. (OSX has problems of it's own, but I'll save that
>for another mail)
>
>The "magic" build script for Win32 contain this fragment of the build
>line for MSVC
>
>/DEF:"./../../engine/api/doomsday.def" /IMPLIB:"./%BIN_DIR
>%/Doomsday.lib"
>
>(Full script is here ->
>http://svn.sourceforge.net/viewvc/deng/trunk/doomsday/build/win32/vcbuild.bat?revision=3509&view=markup )
>
>Somehow it produces a .lib file from the main executable that makes the
>Windows linker happy.
>
>I tried to emulate this in cmake with this:
>
>## Work around for Win32 wanting something for the plugins to link to
>IF (WIN32)
>ADD_LIBRARY (deng STATIC ${DENG_SOURCES} engine/api/doomsday.def)
>TARGET_LINK_LIBRARIES (deng ${SDL_LIBRARY} ${SDLNET_LIBRARY}
>${ZLIB_LIBRARIES}
>${CURSES_LIBRARIES} ${PNG_LIBRARIES} wsock32 winmm gdi32 ole32 user32
>${CMAKE_SOURCE_DIR}/external/lzss/win32/lzss )
>ENDIF (WIN32)

If you want a shared library, why use STATIC.  Remove the STATIC
and it should work.  CMake will do the right thing with the .def file
as the source.

-Bill



More information about the CMake mailing list