[CMake] How can link to a library just like the system libs?

Kermit Mei kermit.mei at gmail.com
Sat Mar 14 10:43:53 EDT 2009


Hello, I have a library which had been installed into my system
under /usr/lib/. When I manually compile it, I must type:
cc -Wall udpcli.c -o cli -lapue

Now, I wrote my cmakelists.txt like this:
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(UDPCS)
FIND_LIBRARY(APUE_LIB, /usr/lib/)
ADD_EXECUTABLE(serv udpserv.c)
ADD_EXECUTABLE(cli udpcli.c)
TARGET_LINK_LIBRARIES(cli, ${APUE_LIB})

And then I encounter the following errors: 
$ cmake -DBUILD_TYPE=debug ..
CMake Error: Attempt to add link library "/usr/lib/libapue.so" to target
"cli," which is not built by this project.
-- Configuring done

How can I settle it?

Thanks.



More information about the CMake mailing list