[CMake] Problems with using libraries that supercede system libraries
cheshirekow
cheshirekow at gmail.com
Mon Apr 11 15:51:42 EDT 2011
I'm pretty new to cmake and I'm trying to port an (early) project with
gtkmm-3.0. The project builds fine with my makefiles, so I know I don't
have errors in the code. I'm running ubuntu lucid so I don't want to
install gtkmm-3.0 (and it's dozen dependencies) in the system locations
(/usr, /usr/local) because when I do that the rest of gnome get's messed
up. So, I have them installed in some development directories:
$HOME/Codes/c/gnome/build
$HOME/Codes/cpp/gnome/build
(The first is for gtk,glib,pango,atk,cairo the second for
gtkmm,glibmm,pangomm,atkmm,cairomm). I'm using Tronic's
LibFindMacros.cmake (and others) from http://zi.fi/cmake/Modules/,
recommended from the wiki:
http://www.itk.org/Wiki/CMake:How_To_Find_Libraries
I've updated the macros to look for the correct versions (i.e. gtk-3.0
instead of 2.4... etc). Before running cmake I export those two paths
above in PKG_CONFIG_PATH. When I run cmake I get the following warning:
Begin paste:
------------------------------------------------------------------------
CMake Warning at src/designer/CMakeLists.txt:8 (add_executable):
Cannot generate a safe runtime search path for target designer because
files in some directories may conflict with libraries in implicit
directories:
runtime library [libgdk_pixbuf-2.0.so.0] in /usr/lib may be hidden
by files in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libpango-1.0.so.0] in /usr/lib may be hidden by
files in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libgio-2.0.so.0] in /usr/lib may be hidden by files
in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libglib-2.0.so.0] in /usr/lib may be hidden by
files in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libcairo.so.2] in /usr/lib may be hidden by files
in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libatk-1.0.so.0] in /usr/lib may be hidden by files
in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libgobject-2.0.so.0] in /usr/lib may be hidden by
files in:
/home/josh/Codes/c/gnome/build/lib
runtime library [libglibmm-2.4.so.1] in /usr/lib may be hidden by
files in:
/home/josh/Codes/c/gnome/build/lib
/home/josh/Codes/cpp/gnome/build/lib
runtime library [libgiomm-2.4.so.1] in /usr/lib may be hidden by
files in:
/home/josh/Codes/c/gnome/build/lib
/home/josh/Codes/cpp/gnome/build/lib
runtime library [libpangomm-1.4.so.1] in /usr/lib may be hidden by
files in:
/home/josh/Codes/cpp/gnome/build/lib
runtime library [libcairomm-1.0.so.1] in /usr/lib may be hidden by
files in:
/home/josh/Codes/cpp/gnome/build/lib
runtime library [libatkmm-1.6.so.1] in /usr/lib may be hidden by
files in:
/home/josh/Codes/cpp/gnome/build/lib
Some of these libraries may not be found correctly.
------------------------------------------------------------------------
end paste
At first I ignored the warning, because I actually want to link with the
newer versions in /home/josh/Codes... but when I run ccmake to view the
cache, the location of the libraries and includes for these components
is listed as /usr/lib, /usr/include... When I try to run make, several
of the header files can't be found and when running make with VERBOSE=1,
the compile command is using the includes from /usr.
my CMakeLists.txt file looks like this:
begin paste:
-------------------------------------------------------
find_package(GTKmm REQUIRED)
link_directories( ${GTKmm_LIBRARY_DIRS} )
include_directories( ${GTKmm_INCLUDE_DIRS} )
add_executable(designer
main.cpp
CBlockCanvas.cpp
CBlockView.cpp
CMainFrame.cpp
CPortView.cpp
CStateGraph.cpp
CStateNodes.cpp )
target_link_libraries(designer ${GTKmm_LIBRARIES})
-------------------------------------------------------
I'm quite sure that PKG_CONFIG_PATH is set correctly, because the cmake
cache has actually found gtkmm-3.0 in /home/josh/Codes. The cmake cache
has the following libraries found in /usr:
atk
atkmm
cairo
cairomm
gdk-pixbuf
gio
giomm
glib
glibmm
pango
pangomm
and the following in /home/josh
gdk
gdkmm
gtk
gtkmm
Note that gtk(mm) and gdk(mm) are the only libraries whose major version
differs from the system's major versions. In otherwords, cmake seems to
be using /home/josh/Codes when it cant find it in /usr... but using the
ones in /usr/ even if it finds them in /home/josh/Codes. What is further
confusing me, is that the versions found by tronics scripts seem to be
the correct ones. For instance, I get the following output from cmake:
begin paste:
--------------------------------------
-- found pango, version 1.28.3
-- found glib-2.0, version 2.28.3
-- found gio-2.0, version 2.28.3
-- found cairo, version 1.10.2
-- found atk, version 1.33.6
-- found glibmm-2.4, version 2.27.96
-- found giomm-2.4, version 2.27.96
-- found cairomm-1.0, version 1.9.8
-- found pangomm-1.4, version 2.27.1
-- found atkmm-1.6, version 2.22.2
---------------------------------------
Which *ARE* the versions in /home/josh/Codes. The system versions are:
pango: 1.28.0
glib: 2.24.1
gio: 2.24.1
etc. etc.
So what am I doing wrong that cmake (or tronics scripts) are finding the
new libraries, and then storing the locations of the system libraries
instead, and using those in the makefiles? It was my understanding that
by providing the search paths of pkg-config in the find_path and
find_library cmake commands, that, if the library was found in these
locations, cmake would stop looking. And, since pkg-config is clearly
finding them in these locations, why is cmake looking further?
I would appreciate any suggestions from people who understand cmake
better than I do.
Thanks,
Josh
More information about the CMake
mailing list