[CMake] Removing overkill linking

Paul McEnery pmcenery at gmail.com
Fri Oct 1 16:27:28 EDT 2010


On 1 October 2010 16:40, Marcel Loose <loose at astron.nl> wrote:
> Hi Paul,
>
> Probably one of the packages that you "pull in" -- dbus, dbug-glib,
> libftdi, libglade, gtk+2, hal -- is introducing this dependency. Check
> the different *_LIBRARIES variables and you'll probably find the fly in
> your ointment.
>
> You may definitely want to look into the LINK_INTERFACE_LIBRARIES option
> of target_link_libraries to avoid over-linking.
>

Thanks Marcel.

I have managed to solve the issue on the shared library, however, I'm
still having an issue with the executable being excessively linked.
I've tried a number of different ways, but don't think I have the
syntax right for what I'm trying to achieve.

====================================
# Dependencies
find_package      (PkgConfig)
pkg_check_modules (DBUS       REQUIRED   dbus-1>=1.2.12)
pkg_check_modules (DBUS-GLIB  REQUIRED   dbus-glib-1>=0.80)
pkg_check_modules (FTDI       REQUIRED   libftdi>=0.13)
pkg_check_modules (GLADE      REQUIRED   libglade-2.0>=2.6.4)
pkg_check_modules (GTK2       REQUIRED   gtk+-2.0>=2.16.1)
pkg_check_modules (HAL        REQUIRED   hal>=0.5.12)

# Main config
add_definitions(-DGLADEFILE="${CMAKE_INSTALL_PREFIX}/${sharedir}/galinette_gtk.glade")
add_definitions(-DGALINETTE_VERSION="${GALINETTE_VERSION}")

# Include & build
include_directories   (. ${DBUS_INCLUDE_DIRS}
${DBUS-GLIB_INCLUDE_DIRS} ${GLADE_INCLUDE_DIRS} ${GTK2_INCLUDE_DIRS}
${HAL_INCLUDE_DIRS})
add_executable        (galinette callbacks.c callbacks.h
galinette-gtk.c galinette_gtk.glade galinette-gtk.h hal.c hal.h
main.c)
add_dependencies      (galinette libgalinette)
target_link_libraries (galinette libgalinette ${DBUS_LIBRARIES}
${DBUS-GLIB_LIBRARIES} ${GLADE_LIBRARIES} ${GTK2_LIBRARIES}
${HAL_LIBRARIES})
target_link_libraries (galinette LINK_INTERFACE_LIBRARIES "")

# Other resources
add_custom_target (galinette_gtk.glade)

# Install
install (TARGETS galinette           DESTINATION ${bindir})
install (FILES   galinette_gtk.glade DESTINATION ${sharedir})
====================================



More information about the CMake mailing list