Index: include/freeDiameter/CMakeLists.txt
===================================================================
--- include/freeDiameter/CMakeLists.txt	(revision 666)
+++ include/freeDiameter/CMakeLists.txt	(revision 668)
@@ -16,8 +16,12 @@
 OPTION(ERRORS_ON_TODO "(development) Generate compilation errors on TODO items ?" OFF)
 
+# Create the absolute path for searching extensions
+SET(DEFAULT_EXTENSIONS_PATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_EXTENSIONS_SUFFIX})
+
+
 MARK_AS_ADVANCED(DISABLE_SCTP DEBUG_SCTP SCTP_USE_MAPPED_ADDRESSES ERRORS_ON_TODO)
 
 ########################
-# System checks 
+### System checks part
 
 INCLUDE (CheckLibraryExists)
@@ -28,6 +32,6 @@
 INCLUDE (TestBigEndian)
 
-# Check byte ordering
-TEST_BIG_ENDIAN(HOST_BIG_ENDIAN)
+
+### System checks -- mandatory support
 
 # We need the getopt_long function
@@ -37,4 +41,16 @@
 ENDIF (NOT HAVE_LONG_OPTIONS)
 
+# getifaddrs ?
+CHECK_FUNCTION_EXISTS (getifaddrs HAVE_GETIFADDRS)
+IF (NOT HAVE_GETIFADDRS)
+   MESSAGE(SEND_ERROR "The getifaddrs function is currently required by freeDiameter.")
+ENDIF (NOT HAVE_GETIFADDRS)
+
+
+### System checks -- for freeDiameter-host.h
+
+# Check byte ordering
+TEST_BIG_ENDIAN(HOST_BIG_ENDIAN)
+
 # Check if ntohll is provided on the system
 CHECK_SYMBOL_EXISTS(ntohll "" HAVE_NTOHLL)
@@ -43,12 +59,10 @@
 CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
 
-# getifaddrs ?
-CHECK_FUNCTION_EXISTS (getifaddrs HAVE_GETIFADDRS)
-IF (NOT HAVE_GETIFADDRS)
-   MESSAGE(SEND_ERROR "The getifaddrs function is currently required by freeDiameter.")
-ENDIF (NOT HAVE_GETIFADDRS)
+
+### System checks -- for includes / link
 
 # pthreads
 INCLUDE(FindThreads)
+SET(CMAKE_THREAD_LIBS_INIT ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE)
 
 # clock_gettime
@@ -67,8 +81,5 @@
    ENDIF (HAVE_LIBRT)
 ENDIF (HAVE_CLOCK_GETTIME)
-
-# LFDPROTO_LIBS = libraries required by the libfdproto.
-SET(LFDPROTO_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE)
-
+SET(CLOCK_GETTIME_LIBS ${CLOCK_GETTIME_LIBS} PARENT_SCOPE)
 
 # dlopen and dlclose: CMAKE_DL_LIBS
@@ -95,8 +106,12 @@
 	MESSAGE(STATUS "Disabled SCTP support.")
 ENDIF(NOT DISABLE_SCTP)
+SET(SCTP_INCLUDE_DIR ${SCTP_INCLUDE_DIR} PARENT_SCOPE)
+SET(SCTP_LIBRARIES ${SCTP_LIBRARIES} PARENT_SCOPE)
 
 
 # Require GNU TLS for building the library
 FIND_PACKAGE(GnuTLS REQUIRED)
+SET(GNUTLS_INCLUDE_DIR ${GNUTLS_INCLUDE_DIR} PARENT_SCOPE)
+SET(GNUTLS_LIBRARIES ${GNUTLS_LIBRARIES} PARENT_SCOPE)
 
 find_path(GCRYPT_INCLUDE_DIR NAMES gcrypt.h)
@@ -105,4 +120,5 @@
 Endif ( NOT GCRYPT_INCLUDE_DIR )
 MARK_AS_ADVANCED(GCRYPT_INCLUDE_DIR)
+SET(GCRYPT_INCLUDE_DIR ${GCRYPT_INCLUDE_DIR} PARENT_SCOPE)
 
 # Also we need libgcrypt to... display its version :(
@@ -113,13 +129,21 @@
 	MESSAGE(SEND_ERROR "Unable to find libgcrypt, please install libgcrypt or equivalent")
 Endif ( NOT GCRYPT_LIBRARY )
+SET(GCRYPT_LIBRARY ${GCRYPT_LIBRARY} PARENT_SCOPE)
 
 
-# LFDCORE_LIBS = libraries required by the libfdcore
-SET(LFDCORE_LIBS ${CMAKE_DL_LIBS} ${SCTP_LIBRARIES} ${GCRYPT_LIBRARY} ${GNUTLS_LIBRARIES} PARENT_SCOPE)
+##########################
+
+# LFDPROTO_LIBS = libraries required by the libfdproto.
+SET(LFDPROTO_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE)
+# Dependencies: the libraries required by any code linking to libfdproto.
+SET(LFDPROTO_LINK_INTERFACES ${CMAKE_THREAD_LIBS_INIT} PARENT_SCOPE)
+
+# LFDCORE_LIBS = libraries required by the libfdcore (in addition to libfdproto and its dependencies)
+SET(LFDCORE_LIBS ${CLOCK_GETTIME_LIBS} ${CMAKE_DL_LIBS} ${SCTP_LIBRARIES} ${GCRYPT_LIBRARY} ${GNUTLS_LIBRARIES} PARENT_SCOPE)
+# And includes paths
 SET(LFDCORE_INCLUDES ${SCTP_INCLUDE_DIR} ${GNUTLS_INCLUDE_DIR} ${GCRYPT_INCLUDE_DIR} PARENT_SCOPE)
-
-##########################
-# Create the absolute path for searching extensions
-SET(DEFAULT_EXTENSIONS_PATH ${CMAKE_INSTALL_PREFIX}/${INSTALL_EXTENSIONS_SUFFIX})
+# And dependencies
+SET(LFDCORE_LINK_INTERFACES "" PARENT_SCOPE) # We don't force any other library, the programs will link with what they needs 
+                                             # (such as libgnutls if they use GNUTLS_DEBUG() macro)
 
 ##########################
