[CMake] Problems with cmake, visualstudio generator and add_library / target_link_libraries

Thomas Veith veith.th at googlemail.com
Wed Sep 24 04:56:44 EDT 2008


Hi *,

when using a simple CMakeLists.txt like the following:

>>>
cmake_minimum_required(VERSION 2.6)
PROJECT(socket)

add_definitions( -D_CRT_SECURE_NO_WARNINGS )

add_library(socket STATIC  ../../src/base64.cpp ../../src/http.cpp
../../src/PoolThread.cpp ../../src/ResourceHandler.cpp
../../src/socket.cpp ../../src/sslsocket.cpp )

target_link_libraries(socket  ws2_32.lib )
<<<

the Visual Studio Generator (2005 or 2008) don't adds ws2_32.lib as
additional dependency to VCLibrarianTool.

The expected outcome would be something like:
			<Tool
				Name="VCLibrarianTool"
				AdditionalDependencies="ws2_32.lib"
				OutputFile="$(OutDir)/$(ProjectName).lib"
				SuppressStartupBanner="true"
			/>
instead it produces:
			<Tool
				Name="VCLibrarianTool"
				OutputFile="D:\exp\lala\common\socket\prj\vc80\Release\socket.lib"/>

With the result that other projects get linker errors because of the
missing ws2_32.lib.

Any help would be appreciated!

best regards,
Thomas


More information about the CMake mailing list