[CMake] msvc linking problem k3b on windows

Ralf Habacker ralf.habacker at freenet.de
Tue Apr 21 07:32:12 EDT 2009


Hi,

while porting k3b to windows I encountered a cmake 2.6.3 problem with 
import libaries names.  The background: 

k3b defines a shared library target named k3b similar the next lines 
from the appended testcase

add_library(k3b SHARED lib.cpp)
target_link_libraries(k3b)

and an executable target named k3b_bin like shown below

add_executable(k3b_bin test.cpp)
target_link_libraries(k3b_bin k3b)

because the executable should be named k3b the OUTPUT_NAME property of 
the executable target is set like shown below.

set_target_properties(k3b_bin PROPERTIES OUTPUT_NAME k3b)

When linking the following error message raised up

E:\daten\kde\emerge-msvc-root\tmp\test\build>nmake

[ 50%] Building CXX object CMakeFiles/k3b.dir/lib.cpp.obj
lib.cpp
Linking CXX shared library k3b.dll
   Creating library k3b.lib and object k3b.exp
[ 50%] Built target k3b
[100%] Building CXX object CMakeFiles/k3b_bin.dir/test.cpp.obj
test.cpp
Linking CXX executable k3b.exe
LINK : fatal error LNK1149: output filename matches input filename 
'E:\daten\kde\emerge-msvc-root\tmp\test\build\k3b.lib'

The executable exports symbols (normal behavior because k3b uses qt 
library templates)  - link tries to create an import library for the 
executable which fails because of the name clash.

For my opinion the problem here is caused by the fact that cmake uses 
the value of the OUPUT_NAME property for creating the import library 
name and not the target name which is expected.

Could this issue be fixed ?

Regards
 Ralf




-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CMakeLists.txt
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090421/531ba2b6/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: lib.cpp
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090421/531ba2b6/attachment.asc>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.cpp
URL: <http://www.cmake.org/pipermail/cmake/attachments/20090421/531ba2b6/attachment-0001.txt>


More information about the CMake mailing list