1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
# Copyright (C) 2010 Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ------ #
# README #
# ------ #
# This file factorizes all rules to define a project for JRL or LAAS.
# It supposes that some variables have already been defined:
# - PROJECT_NAME Project name.
# Please keep respect our coding style and choose a name
# which respects the following regexp: [a-z][a-z0-9-]*
# I.e. a lower-case letter then one or more lower-case
# letter, number or hyphen ``-''.
# - PROJECT_VERSION Project version (X.Y.Z where X, Y, Z are unsigned
# integers). If not defined, it will automatically
# be computed through `git describe`.
# See BASE_COMPUTE_VERSION for more information.
# - PROJECT_DESCRIPTION One line summary of the package goal.
# - PROJECT_URL Project's website.
#
# Please note that functions starting with an underscore are internal
# functions and should not be used directly.
# ---- #
# TODO #
# ---- #
# - make install should trigger make doc
# - unit tests should be tagged as
# EXCLUDE_FROM_ALL and make test should trigger their compilation.
# Include base features.
INCLUDE(cmake/logging.cmake)
INCLUDE(cmake/portability.cmake)
INCLUDE(cmake/compiler.cmake)
INCLUDE(cmake/debian.cmake)
INCLUDE(cmake/dist.cmake)
INCLUDE(cmake/distcheck.cmake)
INCLUDE(cmake/doxygen.cmake)
INCLUDE(cmake/header.cmake)
INCLUDE(cmake/pkg-config.cmake)
INCLUDE(cmake/uninstall.cmake)
INCLUDE(cmake/install-data.cmake)
INCLUDE(cmake/release.cmake)
INCLUDE(cmake/version.cmake)
INCLUDE(cmake/GNUInstallDirs.cmake)
# --------- #
# Constants #
# --------- #
# Variables requires by SETUP_PROJECT.
SET(REQUIRED_VARIABLES PROJECT_NAME PROJECT_DESCRIPTION PROJECT_URL)
# --------------------- #
# Project configuration #
# --------------------- #
# _ADD_TO_LIST LIST VALUE
# -------------
#
# Add a value to a comma-separated list.
#
# LIST : the list.
# VALUE : the value to be appended.
# SEPARATOR : the separation symol.
#
MACRO(_ADD_TO_LIST LIST VALUE SEPARATOR)
IF("${${LIST}}" STREQUAL "")
SET(${LIST} "${VALUE}")
ELSE("${${LIST}}" STREQUAL "")
SET(${LIST} "${${LIST}}${SEPARATOR} ${VALUE}")
ENDIF("${${LIST}}" STREQUAL "")
ENDMACRO(_ADD_TO_LIST LIST VALUE)
# _CONCATE_ARGUMENTS
# -------------
#
# Concatenate all arguments into the output variable.
#
# OUTPUT : the output variable.
# SEPARTOR : the list separation symbol.
# ARG1...ARGN : the values to be concatenated.
#
MACRO(_CONCATENATE_ARGUMENTS OUTPUT SEPARATOR)
FOREACH(I RANGE 2 ${ARGC})
_ADD_TO_LIST("${OUTPUT}" "${ARGV${I}}" "${SEPARATOR}")
ENDFOREACH(I RANGE 2 ${ARGC})
MESSAGE(${${OUTPUT}})
ENDMACRO(_CONCATENATE_ARGUMENTS OUTPUT)
# SETUP_PROJECT
# -------------
#
# Initialize the project. Should be called first in the root
# CMakeList.txt.
#
# This function does not take any argument but check that some
# variables are defined (see documentation at the beginning of this
# file).
#
MACRO(SETUP_PROJECT)
# Check that required variables are defined.
FOREACH(VARIABLE ${REQUIRED_VARIABLES})
IF (NOT DEFINED ${VARIABLE})
MESSAGE(FATAL_ERROR
"Required variable ``${VARIABLE}'' has not been defined.")
ENDIF(NOT DEFINED ${VARIABLE})
ENDFOREACH(VARIABLE)
# Define project name.
PROJECT(${PROJECT_NAME} CXX)
# If the project version number is not set, compute it automatically.
IF(NOT DEFINED PROJECT_VERSION)
VERSION_COMPUTE()
ENDIF()
# Be verbose by default.
SET(CMAKE_VERBOSE_MAKEFILE TRUE)
ENABLE_TESTING()
LOGGING_INITIALIZE()
#FIXME: normalize naming to <MODULE>_SETUP()
_SETUP_PROJECT_WARNINGS()
_SETUP_PROJECT_HEADER()
_SETUP_PROJECT_DIST()
DISTCHECK_SETUP()
RELEASE_SETUP()
_SETUP_PROJECT_DEB()
_SETUP_PROJECT_UNINSTALL()
_SETUP_PROJECT_PKG_CONFIG()
_SETUP_PROJECT_DOCUMENTATION()
ENDMACRO(SETUP_PROJECT)
# SETUP_PROJECT_FINALIZE
# ----------------------
#
# To be called at the end of the CMakeLists.txt to
# finalize the project setup.
#
MACRO(SETUP_PROJECT_FINALIZE)
_SETUP_PROJECT_PKG_CONFIG_FINALIZE()
_SETUP_PROJECT_DOCUMENTATION_FINALIZE()
_SETUP_PROJECT_HEADER_FINAlIZE()
_SETUP_DEBIAN()
# Install data if needed
_INSTALL_PROJECT_DATA()
LOGGING_FINALIZE()
ENDMACRO(SETUP_PROJECT_FINALIZE)
|