view include/freediameter/CMakeLists.txt @ 0:13530e1f02e3

Initial files imported
author Sebastien Decugis <sdecugis@nict.go.jp>
date Fri, 28 Aug 2009 19:14:42 +0900
parents
children
line wrap: on
line source

#CMake configuration for freediameter include directory

Project("FreeDiameter include directory" C)

########################
# Configurable parameters

# Name of the default configuration file
OPTION(DEFAULT_CONF_FILE "Default path to configuration file?" OFF)

# Disable SCTP support completly ?
OPTION(DISABLE_SCTP "Disable SCTP support?")


########################
# System checks 

INCLUDE (CheckLibraryExists)
INCLUDE (CheckFunctionExists)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckSymbolExists) 
INCLUDE (TestBigEndian)

# We use dlopen and dlclose
SET(FD_LIBS ${FD_LIBS} ${CMAKE_DL_LIBS})

# We need the threads library (pthread)
INCLUDE(FindThreads)
SET(FD_LIBS ${FD_LIBS} ${CMAKE_THREAD_LIBS_INIT})

# We need the clock_gettime function ( -lrt, -lposix4 )
CHECK_FUNCTION_EXISTS (clock_gettime HAVE_CLOCK_GETTIME)
IF (HAVE_CLOCK_GETTIME)
   SET(CLOCK_GETTIME_LIBS "")
ELSE (HAVE_CLOCK_GETTIME)
   CHECK_LIBRARY_EXISTS (rt clock_gettime "" HAVE_LIBRT)
   IF (HAVE_LIBRT)
     SET(CLOCK_GETTIME_LIBS "-lrt")
   ELSE (HAVE_LIBRT)
     CHECK_LIBRARY_EXISTS (posix4 clock_gettime "" HAVE_LIBPOSIX4)
     IF (HAVE_LIBPOSIX4)
       SET(CLOCK_GETTIME_LIBS "-lposix4")
     ENDIF (HAVE_LIBPOSIX4)
   ENDIF (HAVE_LIBRT)
ENDIF (HAVE_CLOCK_GETTIME)
SET(FD_LIBS ${FD_LIBS} ${CLOCK_GETTIME_LIBS})

# We need the sctp_getladdrs function ( -lsctp )
# We need the IPPROTO_SCTP symbol from sys/socket.h, netinet/in.h or netinet/sctp.h
IF(NOT DISABLE_SCTP)
	CHECK_FUNCTION_EXISTS(sctp_getladdrs HAVE_NATIVE_SCTP)
	IF(NOT HAVE_NATIVE_SCTP)
		FIND_PACKAGE(SCTP REQUIRED)
		INCLUDE_DIRECTORIES(${SCTP_INCLUDE_DIRS})
		SET(FD_LIBS ${FD_LIBS} ${SCTP_LIBRARIES})
	ENDIF(NOT HAVE_NATIVE_SCTP)
ENDIF(NOT DISABLE_SCTP)

# Check byte ordering
TEST_BIG_ENDIAN(HOST_BIG_ENDIAN)

# We need the getopt_long function
CHECK_FUNCTION_EXISTS (getopt_long HAVE_LONG_OPTIONS)
IF (NOT HAVE_LONG_OPTIONS)
   MESSAGE(SEND_ERROR "The getopt_long function is not found, please add needed library in build system")
ENDIF (NOT HAVE_LONG_OPTIONS)

# Check if ntohll is provided on the system
CHECK_SYMBOL_EXISTS(ntohll "" HAVE_NTOHLL)

# malloc.h ?
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)

# The default configuration file name
IF (NOT DEFAULT_CONF_FILE)
   SET(DEFAULT_CONF_FILE "freediameter.conf")
ENDIF (NOT DEFAULT_CONF_FILE)
##########################

# Generate the host.h file
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/freediameter-host.h.in ${CMAKE_CURRENT_BINARY_DIR}/freediameter-host.h)

# Save the FD_LIBS for parent scope
SET(FD_LIBS ${FD_LIBS} PARENT_SCOPE)
"Welcome to our mercurial repository"