[CMake] Using pkg-config

Marko Anastasov marko at marko.anastasov.name
Mon Dec 18 20:12:56 EST 2006


Hello,

I'm new to CMake. I'm trying to write a CMakeLists.txt file to
build a simple gtkmm test program (should work with any though).
I can build and run it, but I need to fix something.

Here's the main part:

EXEC_PROGRAM(pkg-config ARGS --cflags --libs gtkmm-2.4
             OUTPUT_VARIABLE GTKMM_PKG_FLAGS)
SET(GTKMM_PKG_FLAGS "${GTKMM_PKG_FLAGS}" CACHE STRING "GTKMM Flags")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GTKMM_PKG_FLAGS}")

add_executable(example ${SOURCES})

target_link_libraries(example ${GTKMM_PKG_FLAGS})

For each .o file produced, I get the "linker input file unused because
linking not done" error. Ok, that's because I actually pass the linker
flags when compiling a .cc file. I found:

http://public.kitware.com/pipermail/cmake/2005-January/006061.html

The code above is actually taken from that thread as well.
So I should "use the STRING command's REGEX option to separate the -l
and -L options and send the -L options to LINK_DIRECTORIES".
Does anyone have an example/ready solution for this?

Marko



More information about the CMake mailing list