[CMake] Problems with using libraries that supercede system libraries

Alexander Neundorf a.neundorf-work at gmx.net
Mon Apr 11 16:01:30 EDT 2011


On Monday 11 April 2011, cheshirekow wrote:
> 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:

You should set CMAKE_PREFIX_PATH instead of relying on pkgconfig. Then you can 
be sure that cmake will figure out the stuff in a way that it works (i.e. 
libraries with full paths).

>
> 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}  )

You should not need to call link_directories()...

> 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})

... instead ${GTKmm_LIBRARIES} should be a list of libraries with full path. 
Is that the case ?
What does
message(STATUS "gtkmm: ${GTKmm_LIBRARIES}") give ?

Alex


More information about the CMake mailing list