blob: d41c64520b70f7cb0f37eae490ba2a1e02edc95f [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001# This file is the source for generating the Makefile for the project, using cmake tool (cmake.org)
2
3# Name of the project
4PROJECT("freeDiameter")
5
6# Informations to display in daemon's help
7SET(FD_PROJECT_NAME freeDiameter)
8SET(FD_PROJECT_BINARY freeDiameterd)
9SET(FD_PROJECT_COPYRIGHT "Copyright (c) 2008-2015, WIDE Project (www.wide.ad.jp) and NICT (www.nict.go.jp)")
10
11# Version of the source code
12SET(FD_PROJECT_VERSION_MAJOR 1)
13SET(FD_PROJECT_VERSION_MINOR 2)
14SET(FD_PROJECT_VERSION_REV 1)
15
16# Version of the API with the library
17SET(FD_PROJECT_VERSION_API 6)
18
19# The test framework, using CTest and CDash.
20INCLUDE(CTest)
21
22# CMake version
23CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
24
25# Location of additional CMake modules
26SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
27
28# The default directories
29SET(DEFAULT_CONF_PATH ${CMAKE_INSTALL_PREFIX}/etc/freeDiameter CACHE PATH "Default location of freeDiameter configuration files")
30
31IF (NOT DEFINED LIB_INSTALL_DIR)
32SET(LIB_INSTALL_DIR lib CACHE PATH "Default library path name on the system, to accomodate RPM-based systems that use lib64")
33ENDIF (NOT DEFINED LIB_INSTALL_DIR)
34
35SET(INSTALL_HEADERS_SUFFIX include/freeDiameter CACHE PATH "Directory where the headers are installed (relative to CMAKE_INSTALL_PREFIX).")
36SET(INSTALL_DAEMON_SUFFIX bin CACHE PATH "Directory where the daemon binary is installed (relative to CMAKE_INSTALL_PREFIX).")
37SET(INSTALL_LIBRARY_SUFFIX ${LIB_INSTALL_DIR} CACHE PATH "Directory where the freeDiameter libraries are installed (relative to CMAKE_INSTALL_PREFIX).")
38SET(INSTALL_EXTENSIONS_SUFFIX ${LIB_INSTALL_DIR}/freeDiameter CACHE PATH "Directory where the extensions are installed / searched (relative to CMAKE_INSTALL_PREFIX).")
39
40# All source code should be POSIX 200112L compatible, but some other extensions might be used, so:
41ADD_DEFINITIONS(-D_GNU_SOURCE)
42
43# Set a default build type if none was specified
44if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
45 message(STATUS "Setting build type to 'Debug' as none was specified.")
46 set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
47 # Set the possible values of build type for cmake-gui
48 set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
49 "MinSizeRel" "RelWithDebInfo" "Profiling" "MaxPerformance" "DebianPackage" "DebugValgrind")
50endif()
51
52# Add a "Profiling" build type
53# SET(CMAKE_BUILD_TYPE Profiling)
54SET(CMAKE_C_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage -fstack-protector -g -Wall")
55
56# Add a "MaxPerformance" build type -- this is very silent...
57# SET(CMAKE_BUILD_TYPE MaxPerformance)
58SET(CMAKE_C_FLAGS_MAXPERFORMANCE "${CMAKE_C_FLAGS_RELEASE} -DSTRIP_DEBUG_CODE")
59
60# Add a "DebianPackage" build type used when creating the Debian packages
61SET(CMAKE_C_FLAGS_DEBIANPACKAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
62
63# Set the "Debug" flags
64SET(CMAKE_C_FLAGS_DEBUG "-Wall -g -O0")
65
66# Add a "DebugValgrind" build type used for checking execution with Valgrind tool
67SET(CMAKE_C_FLAGS_DEBUGVALGRIND "-Wall -g -O0")
68
69# Set the DEBUG flag for Debug and Profiling builds
70IF (CMAKE_BUILD_TYPE MATCHES "Debug|Profiling|DebugValgrind")
71 SET(DEBUG 1)
72ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug|Profiling|DebugValgrind")
73
74# some subfolders use yacc and lex parsers
75SET(BISON_GENERATE_DEFINES TRUE)
76SET(BISON_PREFIX_OUTPUTS TRUE)
77INCLUDE(CMakeUserUseBison)
78SET(FLEX_PREFIX_OUTPUTS TRUE)
79INCLUDE(CMakeUserUseFlex)
80IF( NOT BISON_EXECUTABLE OR NOT FLEX_EXECUTABLE )
81 MESSAGE( SEND_ERROR "Bison and Flex are required" )
82ENDIF( NOT BISON_EXECUTABLE OR NOT FLEX_EXECUTABLE )
83# Check that flex is at least 2.5.20 to support bison-bridge
84# how to do the check with cmake???
85
86# Add this to workaround an apparent bug in FreeBSD cmake (already defined in Linux)
87SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-rdynamic")
88
89# For Darwin systems
90IF(APPLE)
91 SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -flat_namespace -undefined dynamic_lookup")
92 SET(CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS "${CMAKE_SHARED_MODULE_CREATE_CXX_FLAGS} -flat_namespace -undefined dynamic_lookup")
93ENDIF(APPLE)
94
95# Location for the include files
96INCLUDE_DIRECTORIES(include)
97INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
98SUBDIRS(include/freeDiameter)
99
100# Location for the source code
101SUBDIRS(libfdproto)
102SUBDIRS(libfdcore)
103SUBDIRS(freeDiameterd)
104
105# Extensions (there is no use of freeDiameter without any extension)
106SUBDIRS(extensions)
107
108# The unary tests directory
109IF ( BUILD_TESTING )
110 SUBDIRS(tests)
111ENDIF ( BUILD_TESTING )
112