[CMake] Issue w/ relative library paths between targets in CMake 2.8 / Visual Studio 9 2008
Ed Loper
eloper at bbn.com
Thu Jun 10 14:34:24 EDT 2010
I have a CMake project that works fine with CMake 2.6, but when I build
Visual Studio output with CMake 2.8, it doesn't seem to get the target
library linking information quite right. Here's a simplified version of
my project:
Project/CMakeLists.txt
-------------------------------------------------------
ADD_SUBDIRECTORY(Foo)
ADD_SUBDIRECTORY(Bar)
-------------------------------------------------------
Project/Foo/CMakeLists.txt
-------------------------------------------------------
SET (LIBRARY Foo)
# [...]
GENERATE_PROJECT (${LIBRARY} "${SOURCE_FILES}" )
ADD_LIBRARY (${LIBRARY} STATIC ${SOURCE_FILES})
-------------------------------------------------------
Project/Bar/CMakeLists.txt
-------------------------------------------------------
# [...]
ADD_EXECUTABLE (${BAR} ${SOURCE_FILES})
TARGET_LINK_LIBRARIES(${FOO} ${BAR})
-------------------------------------------------------
Under CMake 2.6, the Visual Studio project file for Bar would link to
"..\Foo\$(OutDir)\Foo.lib". But under CMake 2.8, it tries to link to
just "Foo.lib", and Visual Studio can't find it. In particular, the
'AdditionalDependencies' field in the vcproj file is different:
=======================================================================
--- old_bar.vcproj
+++ new_bar.vcproj
=======================================================================
<Configuration Name="RelWithDebInfo|Win32"
OutputDirectory="RelWithDebInfo" [...]>
[...]
<Tool Name="VCLinkerTool"
LinkLibraryDependencies="false"
AdditionalOptions=" /STACK:10000000 /machine:I386 /debug"
AdditionalDependencies="$(NOINHERIT) kernel32.lib user32.lib
- gdi32.lib [...] ..\Foo\$(OutDir)\Foo.lib"
+ gdi32.lib [...] Foo.lib"
[...]/>
</Configuration>
=======================================================================
Any idea what might be causing this and/or what I could do to fix it?
Thanks,
-Edward
More information about the CMake
mailing list