[CMake] [cmake] windows dll and TARGET_LINK_LIBRARIES

Werner Smekal smekal at iap.tuwien.ac.at
Fri Oct 10 03:38:18 EDT 2008


Hi Sören,

for shared libraries use (module is for plugins not to be linked to  
executables)

ADD_LIBRARY(MY_DLL SHARED ${ALL_SOURCES} )

and also use test instead of test.exe

TARGET_LINK_LIBRARIES(test MY_DLL)

Does this work?

Werner

On 10.10.2008, at 09:21, Sören Freudiger wrote:

> 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??
>
> Regards,
> SirAnn
>
>
>
>
>
>
>
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake





More information about the CMake mailing list