[CMake] Linker ignores LINK_DIRECTORIES

Gabor Fekete kotrelmaller.borgenbach at gmail.com
Tue Apr 22 09:42:53 EDT 2008


Hi,

I use LINK_DIRECTORIES to specify the library directories for cmake. But during
compilation I see (with CMAKE_VERBOSE_MAKEFILE) that the linker (ld) is not
called with the paths that were specified in LINK_DIRECTORIES.
What can be the reason?

Here is my cmake list file:

PROJECT(rat-server)
SET(NAME testprog)
SET(VERSION 0.0.1)
SET(SRC_DIR ../src)
FILE(GLOB HeaderFiles "${SRC_DIR}/*.h")
FILE(GLOB SourceFiles "${SRC_DIR}/*.c")

#
# Below this line you MAY make modifications.
#
SET(CMAKE_VERBOSE_MAKEFILE ON)

ADD_EXECUTABLE(${NAME} ${SourceFiles})

SET(XTRA_PREFIX $ENV{XTRA_PREFIX})
IF (NOT XTRA_PREFIX)
	SET(XTRA_PREFIX /usr/local)
ENDIF (NOT XTRA_PREFIX)

INCLUDE(FindPkgConfig)
pkg_check_modules(DBUS REQUIRED dbus-1)
pkg_check_modules(SQL REQUIRED sqlite3)
pkg_check_modules(SSL REQUIRED openssl)
INCLUDE_DIRECTORIES(${DBUS_INCLUDE_DIRS} ${SQL_INCLUDE_DIRS}
 ${SSL_INCLUDE_DIRS})
LINK_DIRECTORIES(${DBUS_LIBRARY_DIRS} ${SQL_LIBRARY_DIRS}
 ${SSL_LIBRARY_DIRS})
TARGET_LINK_LIBRARIES(${NAME}
			pthread ipq
			${DBUS_LIBRARIES} ${SQL_LIBRARIES} ${SSL_LIBRARIES} ${RACOMMON_LIBRARIES})

ADD_DEFINITIONS("-Wall" "$ENV{XTRA_FLAGS}")

INSTALL(FILES ./${NAME} DESTINATION ${XTRA_PREFIX}/bin)

ADD_CUSTOM_TARGET(uninstall
	COMMAND "rm" -rf "${XTRA_PREFIX}/bin/${NAME}"
)

When I run make after cmake, ld complains about libipq, but it is indeed present
in the LINK_DIRECTORIES. libipq.a is a static library, if it matters.
LINK_DIRECTORIES is used by gcc when compiling single c files, but not used
for linking.

Thanks,
Gabor


More information about the CMake mailing list