Brian Waters | 13d9601 | 2017-12-08 16:53:31 -0600 | [diff] [blame] | 1 | # This file is the source for generating the Makefile for the project, using cmake tool (cmake.org) |
| 2 | |
| 3 | # Name of the project |
| 4 | PROJECT("freeDiameter") |
| 5 | |
| 6 | # Informations to display in daemon's help |
| 7 | SET(FD_PROJECT_NAME freeDiameter) |
| 8 | SET(FD_PROJECT_BINARY freeDiameterd) |
| 9 | SET(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 |
| 12 | SET(FD_PROJECT_VERSION_MAJOR 1) |
| 13 | SET(FD_PROJECT_VERSION_MINOR 2) |
| 14 | SET(FD_PROJECT_VERSION_REV 1) |
| 15 | |
| 16 | # Version of the API with the library |
| 17 | SET(FD_PROJECT_VERSION_API 6) |
| 18 | |
| 19 | # The test framework, using CTest and CDash. |
| 20 | INCLUDE(CTest) |
| 21 | |
| 22 | # CMake version |
| 23 | CMAKE_MINIMUM_REQUIRED(VERSION 2.6) |
| 24 | |
| 25 | # Location of additional CMake modules |
| 26 | SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") |
| 27 | |
| 28 | # The default directories |
| 29 | SET(DEFAULT_CONF_PATH ${CMAKE_INSTALL_PREFIX}/etc/freeDiameter CACHE PATH "Default location of freeDiameter configuration files") |
| 30 | |
| 31 | IF (NOT DEFINED LIB_INSTALL_DIR) |
| 32 | SET(LIB_INSTALL_DIR lib CACHE PATH "Default library path name on the system, to accomodate RPM-based systems that use lib64") |
| 33 | ENDIF (NOT DEFINED LIB_INSTALL_DIR) |
| 34 | |
| 35 | SET(INSTALL_HEADERS_SUFFIX include/freeDiameter CACHE PATH "Directory where the headers are installed (relative to CMAKE_INSTALL_PREFIX).") |
| 36 | SET(INSTALL_DAEMON_SUFFIX bin CACHE PATH "Directory where the daemon binary is installed (relative to CMAKE_INSTALL_PREFIX).") |
| 37 | SET(INSTALL_LIBRARY_SUFFIX ${LIB_INSTALL_DIR} CACHE PATH "Directory where the freeDiameter libraries are installed (relative to CMAKE_INSTALL_PREFIX).") |
| 38 | SET(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: |
| 41 | ADD_DEFINITIONS(-D_GNU_SOURCE) |
| 42 | |
| 43 | # Set a default build type if none was specified |
| 44 | if(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") |
| 50 | endif() |
| 51 | |
| 52 | # Add a "Profiling" build type |
| 53 | # SET(CMAKE_BUILD_TYPE Profiling) |
| 54 | SET(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) |
| 58 | SET(CMAKE_C_FLAGS_MAXPERFORMANCE "${CMAKE_C_FLAGS_RELEASE} -DSTRIP_DEBUG_CODE") |
| 59 | |
| 60 | # Add a "DebianPackage" build type used when creating the Debian packages |
| 61 | SET(CMAKE_C_FLAGS_DEBIANPACKAGE "${CMAKE_C_FLAGS_RELWITHDEBINFO}") |
| 62 | |
| 63 | # Set the "Debug" flags |
| 64 | SET(CMAKE_C_FLAGS_DEBUG "-Wall -g -O0") |
| 65 | |
| 66 | # Add a "DebugValgrind" build type used for checking execution with Valgrind tool |
| 67 | SET(CMAKE_C_FLAGS_DEBUGVALGRIND "-Wall -g -O0") |
| 68 | |
| 69 | # Set the DEBUG flag for Debug and Profiling builds |
| 70 | IF (CMAKE_BUILD_TYPE MATCHES "Debug|Profiling|DebugValgrind") |
| 71 | SET(DEBUG 1) |
| 72 | ENDIF (CMAKE_BUILD_TYPE MATCHES "Debug|Profiling|DebugValgrind") |
| 73 | |
| 74 | # some subfolders use yacc and lex parsers |
| 75 | SET(BISON_GENERATE_DEFINES TRUE) |
| 76 | SET(BISON_PREFIX_OUTPUTS TRUE) |
| 77 | INCLUDE(CMakeUserUseBison) |
| 78 | SET(FLEX_PREFIX_OUTPUTS TRUE) |
| 79 | INCLUDE(CMakeUserUseFlex) |
| 80 | IF( NOT BISON_EXECUTABLE OR NOT FLEX_EXECUTABLE ) |
| 81 | MESSAGE( SEND_ERROR "Bison and Flex are required" ) |
| 82 | ENDIF( 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) |
| 87 | SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "-rdynamic") |
| 88 | |
| 89 | # For Darwin systems |
| 90 | IF(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") |
| 93 | ENDIF(APPLE) |
| 94 | |
| 95 | # Location for the include files |
| 96 | INCLUDE_DIRECTORIES(include) |
| 97 | INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include) |
| 98 | SUBDIRS(include/freeDiameter) |
| 99 | |
| 100 | # Location for the source code |
| 101 | SUBDIRS(libfdproto) |
| 102 | SUBDIRS(libfdcore) |
| 103 | SUBDIRS(freeDiameterd) |
| 104 | |
| 105 | # Extensions (there is no use of freeDiameter without any extension) |
| 106 | SUBDIRS(extensions) |
| 107 | |
| 108 | # The unary tests directory |
| 109 | IF ( BUILD_TESTING ) |
| 110 | SUBDIRS(tests) |
| 111 | ENDIF ( BUILD_TESTING ) |
| 112 | |