[CMake] Cmake and Win32 plugin linking issues.

William A. Hoffman billlist at nycap.rr.com
Mon Aug 21 09:53:03 EDT 2006


At 09:06 PM 8/20/2006, Jamie Jones wrote:
>On Sun, 2006-08-20 at 11:10 -0400, William A. Hoffman wrote:
>
>> >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
>> 
>
>G'day Bill,
>
>What I want isn't a library that will be used by the final executable, I
>just want to make a library out of the executable to make the linker
>happy, then I will discard the library. Win32 will then find the symbols
>in the main executable when it loads the plugins.


OK, I see what it does...    The plugins actually link to the .exe file.
I did not know you could do that....   I am not sure that can be done from cmake.
We do not support circular referenced libraries which is basically what this is.
Seems like it would be better to re factor the code a bit.  You could make the main
a dll, then write a very small main that just calls WinMain in that dll.   So,
create a DoomsdayMain.dll and have Doomsday.exe and all the plugins link to it.
The code for Doomsday.exe would be reduced to a single main that calls a main found
in DoomsdayMain.dll.   All of the plugins would link to DoomsdayMain.dll.  Having
not looked at the code, I am not sure how hard it would be.  But, it would fix
the build issues on windows and avoid adding non-standard mac flags as well.

-Bill



More information about the CMake mailing list