RobotLocomotion / drake-iiwa-driver

BSD 3-Clause "New" or "Revised" License
24 stars 30 forks source link

Support lcm and gflags libraries CMake namespace #3

Closed fbudin69500 closed 7 years ago

fbudin69500 commented 7 years ago

Older versions of lcm-config.cmake and gflags-config.cmake were not using a namespace for their targets, but newer versions do. Using the CMake *_LIBRARIES variables instead of directly using the targets names allows to use both the old and new versions of the cmake configuration files.

sammy-tri commented 7 years ago

Testing on my system (ubuntu 16.04) I get a link error when using this branch. It looks like the build isn't pulling in the lcm library? (my build environment is a little... odd, I'll admit).

On master the final (successful) link line looks like:

[4/4] : && /usr/lib/ccache/c++      kuka-driver/CMakeFiles/kuka_driver.dir/kuka_driver.cc.o  -o bin/kuka_driver  -rdynamic kuka-fri-build/lib/libFRIClient.a /home/sammy/git/spartan/build/install/lib/liblcm.so.1.3.95 /home/sammy/git/spartan/build/install/lib/libgflags.so.2.2.0 -lpthread -Wl,-rpath,/home/sammy/git/spartan/build/install/lib: && :

On this branch I get:

[4/4] : && /usr/lib/ccache/c++      kuka-driver/CMakeFiles/kuka_driver.dir/kuka_driver.cc.o  -o bin/kuka_driver  -rdynamic kuka-fri-build/lib/libFRIClient.a /home/sammy/git/spartan/build/install/lib/libgflags.so.2.2.0 -lpthread -Wl,-rpath,/home/sammy/git/spartan/build/install/lib: && :

which unsurprisingly fails since the lcm library isn't specified.

fbudin69500 commented 7 years ago

@sammy-tri : Could you tell me how lcm was built on your system? I was able to build this using both the new Spartan branch I am working on and the current Spartan (that uses CMake to build drake). My guess is that in lcmConfig.cmake that you have on your computer, ${lcm_LIBRARIES} is not declared. I could replace that call with directly lcm::lcm, but I am not sure if in your configuration the lcm target is in the lcm namespace. If you can confirm that lcm is defined in its lcm namespace, I can write a patch that is cleaner :)

sammy-tri commented 7 years ago

this LCM came from an older spartan build (so via drake), looks like it's commit c0a0093 from https://github.com/lcm-proj/lcm.git This is also the commit referenced in externals/lcm on drake master, so I don't think updating spartan should make a difference?

FWIW my lcmConfig.cmake looks like:

spartan% cat build/install/lib/lcm/cmake/lcmConfig.cmake
set(LCM_VERSION 1.3.95)
set(LCM_NAMESPACE "")
set(LCM_USE_FILE ${CMAKE_CURRENT_LIST_DIR}/lcmUtilities.cmake)

include(${CMAKE_CURRENT_LIST_DIR}/lcmTargets.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/lcmJavaTargets.cmake)