[CMake] [cmake] windows dll and TARGET_LINK_LIBRARIES

Christian Ehrlicher Ch.Ehrlicher at gmx.de
Fri Oct 10 03:36:14 EDT 2008


-------- Original-Nachricht --------
> Datum: Fri, 10 Oct 2008 09:21:12 +0200
> Von: "Sören Freudiger" <muffmolch at gmx.de>
> An: cmake at cmake.org
> Betreff: [CMake] [cmake] windows dll and TARGET_LINK_LIBRARIES

> Hi
> How to handle windows dll dependences in CMake.
> 
> 
> CMakeList.txt
> =============
> 
> ADD_LIBRARY(MY_DLL MODULE  ${ALL_SOURCES} ) #--> MSVC generates MY_DLL.dll
> and one
>                                             # small MY_DLL.lib that has to
> be linked
>                                             # to projects using MY_DLL.dll
> 
> ADD_EXECUTABLE(test main.cpp)
> TARGET_LINK_LIBRARIES(test.exe MY_DLL) #--> CMake error. module linking
> not
> possible
> 
> # HACK:
> IF(WIN32)
>   TARGET_LINK_LIBRARIES(test.exe
> "$(SolutionDir)$(ConfigurationName)\\${LIB_NAME}.lib") 
> ENDIF()
> 
> =============
>   
> Question:
> How do I avoid the hack??
> 
By using the correct add_library keyword SHARED instead MODULE. See cmake documentation:
"... MODULE libraries are plugins that are not linked into other targets but may be loaded dynamically at runtime using dlopen-like functionality."

HTH
Christian
-- 
GMX Kostenlose Spiele: Einfach online spielen und Spaß haben mit Pastry Passion!
http://games.entertainment.gmx.net/de/entertainment/games/free/puzzle/6169196


More information about the CMake mailing list