Bill Hoffman wrote:
Jean-Sébastien Guay wrote:
Hi Bill,

You should not have to add .lib, CMake should do that for you. If these are libraries that CMake is building as part of the OSG build, then you should only be linking to the target name, and not messing around with low level .lib type of stuff.

That's what we were doing, and it worked for CMake 2.4.x, but as I said, CMake 2.6 seems to add just <libname> to the Additional Dependencies in the generated VS projects (without .lib).

Also, another user added a workaround for nmake builds - the .lib did not seem to be added there either, even in CMake 2.4.x.


Are these bugs? Can you perhaps download the source tree and try to generate a VS project, and see if the Additional Dependencies in the generated project files are correct on your side?

We have no CMake experts in this project, we're just trying to get something that works...


In the simple case, I just tested with 2.4.8 and 2.6.0 this works fine:

add_executable(bar foo.c)
target_link_libraries(bar foo)

foo.lib is linked for both vs IDE and makefiles.

Let's go back to the macro LINK_INTERNAL. I think the issue was trying to get around a bug in 2.4.7. That should all be fixed in 2.4.8.

So, I think you don't need the macro at all for 2.4.8 and greater.

It should just be:

target_link_libraries(osgDB osg OpenThreads)

Are all the input libraries to LINK_INTERNAL things that CMake is building?

-Bill

OK, I am replying to myself....


I talked with Brad King, who made most of the changes for the link stuff in 2.6. I think he figured out what is going on.

Here is what he said:

In the link computation if the user provides a full path we trust them
and use it verbatim.  I have no idea why they think they need to leave
off the .lib though.

> > why was this necessary in the first place

The code reproduces their problem:

  cmake_minimum_required(VERSION 2.4)
  project(FOO C)
  add_library(foo SHARED foo.c)
  set_target_properties(foo PROPERTIES IMPORT_PREFIX imp PREFIX lib)
  add_executable(bar bar.c)
  target_link_libraries(bar foo)

It works fine in 2.6 but 2.4 tries to link to "libfoo.lib" instead of
"impfoo.lib".

The proper fix is to just take out the work-around when using
CMake 2.6 or higher.

So, I think the fix should be to change the macro LINK_INTERNAL to check the version of CMake and if it is 2.6 or greater, it should just pass the arguments to target_link_libraries directly with no modification. Something like this:

MACRO(LINK_INTERNAL TRGTNAME)
  IF(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
    TARGET_LINK_LIBRARIES(${TRGTNAME}  ${ARGN})
  ELSE(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.5)
    ....


-Bill
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to