[Cmake] Static library linking
Iker Arizmendi
iker at research.att.com
Thu, 15 Apr 2004 12:02:19 -0400
I'm trying to have an executable link against the
static Postgres library, but for some reason CMake
insists on generating a link line that refers to
the shared version though I specify otherwise.
The following CMake snippet:
INCLUDE_DIRECTORIES(${asrdb_SOURCE_DIR}/src)
ADD_EXECUTABLE(dbadmin dbadmin.cpp dbadmin-args.cpp)
MESSAGE(STATUS "Postgres Library: ${PGSQL_STATIC_LIB}")
TARGET_LINK_LIBRARIES(dbadmin asrdb ${PGSQL_STATIC_LIB})
where PGSQL_STATIC_LIB points to "/usr/lib/libpq.a" and
asrdb is my own static library which uses functions exported
by libpq.a. This results in the following output:
Building dependencies. cmake.depends...
/usr/bin/cmake -S/home/iker/network/proj/asrdb/dbadmin
-O/home/iker/proj/build/asrdb/dbadmin -H/home/iker/network/proj/asrdb
-B/home/iker/proj/build/asrdb
-- Postgres Library: /usr/lib/libpq.a
...
...
Building object file dbadmin.o...
/usr/bin/g++ -o dbadmin.o -g -fno-inline -Wall -fmessage-length=0
-I/home/iker/network/proj/asrdb/dbadmin
-I/home/iker/network/proj/asrdb/src -c
/home/iker/network/proj/asrdb/dbadmin/dbadmin.cpp
Building object file dbadmin-args.o...
/usr/bin/g++ -o dbadmin-args.o -g -fno-inline -Wall -fmessage-length=0
-I/home/iker/network/proj/asrdb/dbadmin
-I/home/iker/network/proj/asrdb/src -c
/home/iker/network/proj/asrdb/dbadmin/dbadmin-args.cpp
PROBLEM HERE...
Building executable /home/iker/proj/build/asrdb/dbadmin/dbadmin...
/usr/bin/g++ -g -fno-inline -Wall -fmessage-length=0 -fPIC
dbadmin.o dbadmin-args.o -o
/home/iker/proj/build/asrdb/dbadmin/dbadmin -rdynamic
-L/home/iker/proj/build/asrdb/src -lasrdb -lpq
-Wl,-rpath,/home/iker/proj/build/asrdb/src
The link line above refers to "-lpq" instead of "/usr/lib/libpq.a".
Is CMake doing the wrong thing here? Other posts on the mailing
list suggest this is the way to do this.
Iker
--
Iker Arizmendi
AT&T Labs - Research
Speech and Image Processing Lab
e: iker at research.att.com
w: http://research.att.com