diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f02435f2..7945edbfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8) project(catkin) # the following lines must be the same as in catkin/cmake/catkinConfig.cmake.in -set(catkin_BUILD_PREFIX ${CMAKE_BINARY_DIR}/buildspace CACHE PATH "catkin buildspace") +set(CATKIN_BUILD_PREFIX ${CMAKE_BINARY_DIR}/buildspace CACHE PATH "catkin buildspace") set(catkin_EXTRAS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/cmake CACHE PATH "catkin extras") list(INSERT CMAKE_PREFIX_PATH 0 ${CMAKE_BINARY_DIR}/buildspace) set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} PARENT_SCOPE) @@ -18,20 +18,20 @@ catkin_project(catkin) # for backward compatibility we provide ROSConfig(-version).cmake files file(COPY cmake/ROSConfig.cmake - DESTINATION ${catkin_BUILD_PREFIX}/share/ros/cmake + DESTINATION ${CATKIN_BUILD_PREFIX}/share/ros/cmake ) set(PROJECT_VERSION ${catkin_VERSION}) configure_file(${catkin_EXTRAS_DIR}/templates/pkgConfig-version.cmake.in - ${catkin_BUILD_PREFIX}/share/ros/cmake/ROSConfig-version.cmake + ${CATKIN_BUILD_PREFIX}/share/ros/cmake/ROSConfig-version.cmake @ONLY ) -install(FILES ${catkin_BUILD_PREFIX}/share/ros/cmake/ROSConfig.cmake ${catkin_BUILD_PREFIX}/share/ros/cmake/ROSConfig-version.cmake +install(FILES ${CATKIN_BUILD_PREFIX}/share/ros/cmake/ROSConfig.cmake ${CATKIN_BUILD_PREFIX}/share/ros/cmake/ROSConfig-version.cmake DESTINATION share/ros/cmake ) # for compatibility we provide eigen-config(-version).cmake files file(COPY cmake/Modules/eigen-config.cmake cmake/Modules/eigen-config-version.cmake - DESTINATION ${catkin_BUILD_PREFIX}/share/eigen/cmake + DESTINATION ${CATKIN_BUILD_PREFIX}/share/eigen/cmake ) install(FILES cmake/Modules/eigen-config.cmake cmake/Modules/eigen-config-version.cmake DESTINATION share/eigen/cmake @@ -47,4 +47,4 @@ install(DIRECTORY cmake catkin_python_setup() -add_nosetests(test) +catkin_add_nosetests(test) diff --git a/bin/CMakeLists.txt b/bin/CMakeLists.txt index 1e703f8e1..b4da9b4ea 100644 --- a/bin/CMakeLists.txt +++ b/bin/CMakeLists.txt @@ -14,13 +14,13 @@ set(programs # install all programs install(PROGRAMS ${programs} - DESTINATION ${GLOBAL_BIN_DESTINATION} + DESTINATION bin ) # generate relay-script for each program foreach(program ${programs}) set(EXECUTABLE ${catkin_SOURCE_DIR}/bin/${program}) configure_file(${catkin_EXTRAS_DIR}/templates/script.sh.in - ${catkin_BUILD_PREFIX}/${GLOBAL_BIN_DESTINATION}/${program} + ${CATKIN_BUILD_PREFIX}/bin/${program} @ONLY) endforeach() diff --git a/cmake/all.cmake b/cmake/all.cmake index 5b017e3e3..16119e7be 100644 --- a/cmake/all.cmake +++ b/cmake/all.cmake @@ -4,8 +4,8 @@ if(_CATKIN_ALL_INCLUDED_) endif() set(_CATKIN_ALL_INCLUDED_ TRUE) -if(NOT catkin_BUILD_PREFIX) - message(FATAL_ERROR "\ncatkin_BUILD_PREFIX is not set\n") +if(NOT CATKIN_BUILD_PREFIX) + message(FATAL_ERROR "\nCATKIN_BUILD_PREFIX is not set\n") endif() if(NOT catkin_EXTRAS_DIR) message(FATAL_ERROR "\ncatkin_EXTRAS_DIR is not set\n") @@ -33,7 +33,6 @@ cmake_policy(SET CMP0017 NEW) list(APPEND CMAKE_MODULE_PATH ${catkin_EXTRAS_DIR}/Modules) -# XXX move stuff to separate folders # functions/macros: list_append_unique, safe_execute_process # python-integration: catkin_python_setup.cmake, interrogate_setup_dot_py.py, templates/__init__.py.in, templates/script.py.in, templates/python_distutils_install.bat.in, templates/python_distutils_install.sh.in, templates/safe_execute_install.cmake.in foreach(filename @@ -55,6 +54,7 @@ foreach(filename platform/lsb platform/ubuntu platform/windows + rosbuild_compat test/download_test_data test/gtest test/nosetests @@ -63,8 +63,6 @@ foreach(filename tools/libraries tools/rt -# install_matching_to_share -# rosbuild_compat # tools/threads ) include(${catkin_EXTRAS_DIR}/${filename}.cmake) @@ -79,9 +77,9 @@ catkin_generate_environment() # environment to call external processes if(CMAKE_HOST_UNIX) # true for linux, apple, mingw-cross and cygwin - set(CATKIN_ENV ${catkin_BUILD_PREFIX}/env.sh CACHE INTERNAL "catkin environment") + set(CATKIN_ENV ${CATKIN_BUILD_PREFIX}/env.sh CACHE INTERNAL "catkin environment") else() - set(CATKIN_ENV ${catkin_BUILD_PREFIX}/env.bat CACHE INTERNAL "catkin environment") + set(CATKIN_ENV ${CATKIN_BUILD_PREFIX}/env.bat CACHE INTERNAL "catkin environment") endif() # add additional environment hooks diff --git a/cmake/catkinConfig.cmake.in b/cmake/catkinConfig.cmake.in index 476c47e04..280dc830f 100644 --- a/cmake/catkinConfig.cmake.in +++ b/cmake/catkinConfig.cmake.in @@ -58,9 +58,9 @@ foreach(workspace ${workspaces}) endforeach() # the following lines must be the same as in catkin/CMakeLists.txt -set(catkin_BUILD_PREFIX ${CMAKE_BINARY_DIR}/buildspace CACHE PATH "catkin buildspace") +set(CATKIN_BUILD_PREFIX ${CMAKE_BINARY_DIR}/buildspace CACHE PATH "catkin buildspace") # compare boolean as string since policy CMP0012 is only enabled afterwards -if("@PKG_BUILDSPACE@" STREQUAL "TRUE") +if("@BUILDSPACE@" STREQUAL "TRUE") set(catkin_EXTRAS_DIR @catkin_EXTRAS_DIR@) else() set(catkin_EXTRAS_DIR @PKG_CMAKE_DIR@) diff --git a/cmake/catkin_add_env_hooks.cmake b/cmake/catkin_add_env_hooks.cmake index 1b8f4c16d..26ba934b4 100644 --- a/cmake/catkin_add_env_hooks.cmake +++ b/cmake/catkin_add_env_hooks.cmake @@ -1,33 +1,42 @@ # -# For each shell in ``SHELLS``, ``..in`` in the +# Register environment hooks which are executed by the setup script. +# +# For each shell in ``SHELLS``, ``..in`` in the # directory ``DIRECTORY`` is expand to ``etc/catkin/profile.d/``, # where it will be read by generated ``setup.``. # -# The template can distinguish between build- and installspace using -# the boolean parameters ``ENV_BUILDSPACE`` and ``ENV_INSTALLSPACE`` +# The template can distinguish between build- and installspace +# using the boolean variables ``BUILDSPACE`` and ``INSTALLSPACE`` # which are either ``true`` or ``false``. # # .. note:: Note the extra ".in" that must appear in the filename -# that does not appear in the argument. +# that does not appear in the argument. # -# **NOTE** These files will share a single directory with other -# packages that choose to install env hooks. Be careful to give the -# file a unique name. Typically ``NNprojectname.sh`` is used, where -# NN can define when something should be run (the files are read in -# alphanumeric order) and ``projectname`` serves to disambiguate in -# the event of collision. +# .. note:: These files will share a single directory with other +# packages that choose to install env hooks. Be careful to give +# the file a unique name. Typically ``NN.name.`` is used, +# where NN can define when something should be run (the files are +# read in alphanumeric order) and the name serves to disambiguate +# in the event of collisions. # -# :param SHELLS: list of shells (i.e.: sh bat) -# :param DIRECTORY: Directory of the env hooks (default ${CMAKE_CURRENT_SOURCE_DIR}) +# :param file_prefix: the filename prefix +# :type file_prefix: string +# :param SHELLS: the shell extensions (i.e.: sh bat) +# :type SHELLS: list of strings +# :param DIRECTORY: the directory (default: ${CMAKE_CURRENT_SOURCE_DIR}) +# :type DIRECTORY: string # :param SKIP_INSTALL: if specified the env hooks are only generated # in the buildspace but not installed +# :type SKIP_INSTALL: option +# +# @public # -function(catkin_add_env_hooks ARG_ENV_HOOK) +function(catkin_add_env_hooks file_prefix) parse_arguments(ARG "DIRECTORY;SHELLS" "SKIP_INSTALL" ${ARGN}) # create directory if necessary - if(NOT IS_DIRECTORY ${catkin_BUILD_PREFIX}/etc/catkin/profile.d) - file(MAKE_DIRECTORY ${catkin_BUILD_PREFIX}/etc/catkin/profile.d) + if(NOT IS_DIRECTORY ${CATKIN_BUILD_PREFIX}/etc/catkin/profile.d) + file(MAKE_DIRECTORY ${CATKIN_BUILD_PREFIX}/etc/catkin/profile.d) endif() if(NOT ARG_DIRECTORY) @@ -35,18 +44,18 @@ function(catkin_add_env_hooks ARG_ENV_HOOK) endif() foreach(shell ${ARG_SHELLS}) - set(ENV_HOOK ${ARG_ENV_HOOK}.${shell}) + set(ENV_HOOK ${file_prefix}.${shell}) assert_file_exists(${ARG_DIRECTORY}/${ENV_HOOK}.in "User-supplied environment file '${ARG_DIRECTORY}/${ENV_HOOK}.in' missing") # generate environment hook for buildspace - set(ENV_BUILDSPACE true) - set(ENV_INSTALLSPACE false) + set(BUILDSPACE true) + set(INSTALLSPACE false) configure_file(${ARG_DIRECTORY}/${ENV_HOOK}.in - ${catkin_BUILD_PREFIX}/etc/catkin/profile.d/${ENV_HOOK}) + ${CATKIN_BUILD_PREFIX}/etc/catkin/profile.d/${ENV_HOOK}) # generate and install environment hook for installspace - set(ENV_BUILDSPACE false) - set(ENV_INSTALLSPACE true) + set(BUILDSPACE false) + set(INSTALLSPACE true) configure_file(${ARG_DIRECTORY}/${ENV_HOOK}.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${ENV_HOOK}) if(NOT ${ARG_SKIP_INSTALL}) diff --git a/cmake/catkin_generate_environment.cmake b/cmake/catkin_generate_environment.cmake index 6b4c4e6ca..34672ea93 100644 --- a/cmake/catkin_generate_environment.cmake +++ b/cmake/catkin_generate_environment.cmake @@ -1,28 +1,28 @@ function(catkin_generate_environment) # buildspace - set(SETUP_DIR ${catkin_BUILD_PREFIX}) - set(CURRENT_WORKSPACE ${catkin_BUILD_PREFIX}:${CMAKE_SOURCE_DIR}) + set(SETUP_DIR ${CATKIN_BUILD_PREFIX}) + set(CURRENT_WORKSPACE ${CATKIN_BUILD_PREFIX}:${CMAKE_SOURCE_DIR}) # create workspace marker - file(WRITE ${catkin_BUILD_PREFIX}/CATKIN_WORKSPACE "") + file(WRITE ${CATKIN_BUILD_PREFIX}/CATKIN_WORKSPACE "") # copy setup.py file(COPY ${catkin_EXTRAS_DIR}/templates/setup.py - DESTINATION ${catkin_BUILD_PREFIX}) + DESTINATION ${CATKIN_BUILD_PREFIX}) if(NOT MSVC) # non-windows # generate env configure_file(${catkin_EXTRAS_DIR}/templates/env.sh.in - ${catkin_BUILD_PREFIX}/env.sh + ${CATKIN_BUILD_PREFIX}/env.sh @ONLY) # generate setup for various shells em_expand(${catkin_EXTRAS_DIR}/templates/setup.context.py.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.buildspace.context.py ${catkin_EXTRAS_DIR}/em/setup.sh.em - ${catkin_BUILD_PREFIX}/setup.sh) + ${CATKIN_BUILD_PREFIX}/setup.sh) foreach(shell bash zsh) configure_file(${catkin_EXTRAS_DIR}/templates/setup.${shell}.in - ${catkin_BUILD_PREFIX}/setup.${shell} + ${CATKIN_BUILD_PREFIX}/setup.${shell} @ONLY) endforeach() @@ -30,13 +30,13 @@ function(catkin_generate_environment) # windows # generate env configure_file(${catkin_EXTRAS_DIR}/templates/env.bat.in - ${catkin_BUILD_PREFIX}/env.bat + ${CATKIN_BUILD_PREFIX}/env.bat @ONLY) # generate setup em_expand(${catkin_EXTRAS_DIR}/templates/setup.context.py.in ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.buildspace.context.py ${catkin_EXTRAS_DIR}/em/setup.bat.em - ${catkin_BUILD_PREFIX}/setup.bat) + ${CATKIN_BUILD_PREFIX}/setup.bat) endif() # installspace @@ -46,7 +46,7 @@ function(catkin_generate_environment) if(NOT CATKIN_BUILD_BINARY_PACKAGE OR "${PROJECT_NAME}" STREQUAL "catkin") # install workspace marker install(FILES - ${catkin_BUILD_PREFIX}/CATKIN_WORKSPACE + ${CATKIN_BUILD_PREFIX}/CATKIN_WORKSPACE DESTINATION ${CMAKE_INSTALL_PREFIX}) # install setup.py install(PROGRAMS diff --git a/cmake/catkin_project.cmake b/cmake/catkin_project.cmake index 93950cb9e..f3344e26b 100644 --- a/cmake/catkin_project.cmake +++ b/cmake/catkin_project.cmake @@ -1,49 +1,75 @@ # +# Set a name for the catkin project. +# # It creates the CMake stuff necessary for ``find_package`` to work # (i.e. to be *found* by others that call ``find_package``) and # provide information about include directories, libraries, # further dependencies and CMake variables for dependent projects. # -# Best practice is to call this macro early in your CMakeLists.txt, -# immediately after calling ``project()`` and ``find_package(catkin REQUIRED)``. +# It installs ``manifest.xml`` to ``share/${PROJECT_NAME}``. +# +# .. note:: It must be called once for each package. Best practice +# is to call this macro early in your CMakeLists.txt, immediately +# after calling ``project()``, ``find_package(catkin REQUIRED)`` +# and ``catkin_stack()``. # -# :param catkin_project_name: requires the same value as passed to -# CMake's ``project()`` (*may be vestigial*) +# :param catkin_project_name: the catkin project name which must be +# the same value as passed to CMake's ``project()`` +# :type catkin_project_name: string # :param INCLUDE_DIRS: ``CMAKE_CURRENT_SOURCE_DIR``-relative paths to # C/C++ includes +# :type INCLUDE_DIRS: list of strings # :param LIBRARIES: names of library targets that will appear in the -# ``catkin_LIBRARIES`` and ``${PROJECT_NAME}_LIBRARIES of other +# ``catkin_LIBRARIES`` and ``${PROJECT_NAME}_LIBRARIES`` of other # projects that search for you via ``find_package``. Currently # this will break if the logical target names are not the same as # the installed names. -# :param DEPENDS: The argument ``DEPENDS`` is used when client code -# finds us via ``find_package()``. Each project listed will in -# turn be ``find_package``\ -ed and their ``INCLUDE_DIRS`` and -# ``LIBRARIES`` will be appended to ours. Only catkin projects -# should be used where we can ensure that they are -# *find_packagable* and *package_configurable*. -# :param CFG_EXTRAS: Any extra CMake stuff that should be accessible -# to users of the project. This file should live in subdirectory -# ``cmake`` and have extension ``.in``. It will be expanded by -# CMake's ``configure_file()`` and made available to clients in -# both the install and build spaces: be sure it works both ways. -# TODO: document which variables are available in these templates -# (boolean @PKG_BUILDSPACE@, boolean @PKG_INSTALLSPACE@). -# :outvar PROJECT_INCLUDE_DESTINATION: set to -# ``include``. -# For use with CMake ``install()`` macro as destination argument. -# :outvar PROJECT_LIB_DESTINATION: set to -# ``lib``. -# For use with CMake ``install()`` macro as destination argument. -# :outvar PROJECT_LIBEXEC_DESTINATION: set to -# ``lib/${PROJECT_NAME}``. -# For use with CMake ``install()`` macro as destination argument. -# :outvar PROJECT_PYTHON_DESTINATION: set to -# ``lib/python${PYTHON_VERSION_XDOTY}/${PYTHON_PACKAGES_DIR}/${PROJECT_NAME}``. -# For use with CMake ``install()`` macro as destination argument. -# :outvar PROJECT_SHARE_DESTINATION: set to -# ``share/${PROJECT_NAME}``. -# For use with CMake ``install()`` macro as destination argument. +# :type LIBRARIES: list of strings +# :param DEPENDS: a list of projects which this project depends on. +# It is used when client code finds this project via +# ``find_package()``. Each project listed will in turn be +# ``find_package``\ -ed and their ``INCLUDE_DIRS`` and ``LIBRARIES`` +# will be appended to ours. Only catkin projects should be used +# where we can ensure that they are *find_packagable* and +# *package_configurable*. +# :type DEPENDS: list of strings +# :param CFG_EXTRAS: a CMake file containing extra stuff that should +# be accessible to users of this project after +# ``find_package``\ -ing it. This file should live in the +# subdirectory ``cmake`` and must have an additional extension +# ``.in`` (since it is expanded using CMake's ``configure_file()``). +# The template can distinguish between build- and installspace +# using the boolean variables ``BUILDSPACE`` and ``INSTALLSPACE`` +# and should be verified to work in both cases. +# :type DEPENDS: list of strings +# +# :outvar CATKIN_PROJECT_BIN_DESTINATION: +# See :cmake:data:`CATKIN_PROJECT_BIN_DESTINATION`. +# :outvar CATKIN_PROJECT_ETC_DESTINATION: +# See :cmake:data:`CATKIN_PROJECT_ETC_DESTINATION`. +# :outvar CATKIN_PROJECT_INCLUDE_DESTINATION: +# See :cmake:data:`CATKIN_PROJECT_INCLUDE_DESTINATION`. +# :outvar CATKIN_PROJECT_LIB_DESTINATION: +# See :cmake:data:`CATKIN_PROJECT_LIB_DESTINATION`. +# :outvar CATKIN_PROJECT_PYTHON_DESTINATION: +# See :cmake:data:`CATKIN_PROJECT_PYTHON_DESTINATION`. +# :outvar CATKIN_PROJECT_SHARE_DESTINATION: +# See :cmake:data:`CATKIN_PROJECT_SHARE_DESTINATION`. +# +# :outvar CATKIN_GLOBAL_BIN_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_BIN_DESTINATION`. +# :outvar CATKIN_GLOBAL_ETC_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_ETC_DESTINATION`. +# :outvar CATKIN_GLOBAL_INCLUDE_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_INCLUDE_DESTINATION`. +# :outvar CATKIN_GLOBAL_LIB_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_LIB_DESTINATION`. +# :outvar CATKIN_GLOBAL_LIBEXEC_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_LIBEXEC_DESTINATION`. +# :outvar CATKIN_GLOBAL_PYTHON_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_PYTHON_DESTINATION`. +# :outvar CATKIN_GLOBAL_SHARE_DESTINATION: +# See :cmake:data:`CATKIN_GLOBAL_SHARE_DESTINATION`. # # Example: # :: @@ -54,6 +80,8 @@ # CFG_EXTRAS proj-extras.cmake # ) # +# @public +# function(catkin_project catkin_project_name) debug_message(10 "catkin_project(${catkin_project_name}) called in file ${CMAKE_CURRENT_LIST_FILE}") @@ -87,10 +115,10 @@ function(catkin_project catkin_project_name) # BUILDSPACE # - set(PKG_BUILDSPACE TRUE) - set(PKG_INSTALLSPACE FALSE) + set(BUILDSPACE TRUE) + set(INSTALLSPACE FALSE) - set(PROJECT_SPACE_DIR ${catkin_BUILD_PREFIX}) + set(PROJECT_SPACE_DIR ${CATKIN_BUILD_PREFIX}) set(PKG_INCLUDE_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}) # absolute path to include dirs and validate that they are existing either absolute or relative to projects source @@ -112,12 +140,12 @@ function(catkin_project catkin_project_name) set(PKG_CMAKE_DIR ${PROJECT_SPACE_DIR}/share/${PROJECT_NAME}/cmake) # ensure that output folder exists - file(MAKE_DIRECTORY ${catkin_BUILD_PREFIX}/lib/pkgconfig) + file(MAKE_DIRECTORY ${CATKIN_BUILD_PREFIX}/lib/pkgconfig) # generate buildspace pc for project em_expand(${catkin_EXTRAS_DIR}/templates/pkg.context.pc.in ${CMAKE_CURRENT_BINARY_DIR}/pkg.buildspace.context.pc.py ${catkin_EXTRAS_DIR}/em/pkg.pc.em - ${catkin_BUILD_PREFIX}/lib/pkgconfig/${PROJECT_NAME}.pc) + ${CATKIN_BUILD_PREFIX}/lib/pkgconfig/${PROJECT_NAME}.pc) # generate buildspace config for project set(infile ${${PROJECT_NAME}_EXTRAS_DIR}/${PROJECT_NAME}Config.cmake.in) @@ -125,13 +153,13 @@ function(catkin_project catkin_project_name) set(infile ${catkin_EXTRAS_DIR}/templates/pkgConfig.cmake.in) endif() configure_file(${infile} - ${catkin_BUILD_PREFIX}/share/${PROJECT_NAME}/cmake/${PROJECT_NAME}Config.cmake + ${CATKIN_BUILD_PREFIX}/share/${PROJECT_NAME}/cmake/${PROJECT_NAME}Config.cmake @ONLY ) # generate buildspace config-version for project configure_file(${catkin_EXTRAS_DIR}/templates/pkgConfig-version.cmake.in - ${catkin_BUILD_PREFIX}/share/${PROJECT_NAME}/cmake/${PROJECT_NAME}Config-version.cmake + ${CATKIN_BUILD_PREFIX}/share/${PROJECT_NAME}/cmake/${PROJECT_NAME}Config-version.cmake @ONLY ) @@ -140,7 +168,7 @@ function(catkin_project catkin_project_name) assert_file_exists(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${extra}.in "Nonexistent extra") #configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/${extra}.in configure_file(cmake/${extra}.in - ${catkin_BUILD_PREFIX}/share/${PROJECT_NAME}/cmake/${extra} + ${CATKIN_BUILD_PREFIX}/share/${PROJECT_NAME}/cmake/${extra} @ONLY ) endforeach() @@ -149,8 +177,8 @@ function(catkin_project catkin_project_name) # INSTALLSPACE # - set(PKG_BUILDSPACE FALSE) - set(PKG_INSTALLSPACE TRUE) + set(BUILDSPACE FALSE) + set(INSTALLSPACE TRUE) set(PROJECT_SPACE_DIR ${CMAKE_INSTALL_PREFIX}) set(PKG_INCLUDE_PREFIX ${PROJECT_SPACE_DIR}) @@ -220,20 +248,27 @@ function(catkin_project catkin_project_name) # # set project specific output directory for libraries - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/lib PARENT_SCOPE) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/lib PARENT_SCOPE) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/lib PARENT_SCOPE) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/lib PARENT_SCOPE) # set project specific output directory for binaries - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/lib/${PROJECT_NAME} PARENT_SCOPE) + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/lib/${PROJECT_NAME} PARENT_SCOPE) + + # set global install destinations + set(CATKIN_GLOBAL_BIN_DESTINATION bin PARENT_SCOPE) + set(CATKIN_GLOBAL_ETC_DESTINATION etc PARENT_SCOPE) + set(CATKIN_GLOBAL_INCLUDE_DESTINATION include PARENT_SCOPE) + set(CATKIN_GLOBAL_LIB_DESTINATION lib PARENT_SCOPE) + set(CATKIN_GLOBAL_LIBEXEC_DESTINATION lib PARENT_SCOPE) + set(CATKIN_GLOBAL_PYTHON_DESTINATION ${PYTHON_INSTALL_DIR} PARENT_SCOPE) + set(CATKIN_GLOBAL_SHARE_DESTINATION share PARENT_SCOPE) # set project specific install destinations - set(PROJECT_INCLUDE_DESTINATION include PARENT_SCOPE) - set(PROJECT_LIB_DESTINATION lib PARENT_SCOPE) - set(PROJECT_LIBEXEC_DESTINATION lib/${PROJECT_NAME} PARENT_SCOPE) - set(PROJECT_PYTHON_DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME} PARENT_SCOPE) - set(PROJECT_SHARE_DESTINATION share/${PROJECT_NAME} PARENT_SCOPE) - - # set global install destinations for core binaries - set(GLOBAL_BIN_DESTINATION bin PARENT_SCOPE) + set(CATKIN_PROJECT_BIN_DESTINATION lib/${PROJECT_NAME} PARENT_SCOPE) + set(CATKIN_PROJECT_ETC_DESTINATION etc/${PROJECT_NAME} PARENT_SCOPE) + set(CATKIN_PROJECT_INCLUDE_DESTINATION include/${PROJECT_NAME} PARENT_SCOPE) + set(CATKIN_PROJECT_LIB_DESTINATION lib PARENT_SCOPE) + set(CATKIN_PROJECT_PYTHON_DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME} PARENT_SCOPE) + set(CATKIN_PROJECT_SHARE_DESTINATION share/${PROJECT_NAME} PARENT_SCOPE) # install manifest.xml if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/manifest.xml) diff --git a/cmake/catkin_python_setup.cmake b/cmake/catkin_python_setup.cmake index 2dd0add20..8097b88ba 100644 --- a/cmake/catkin_python_setup.cmake +++ b/cmake/catkin_python_setup.cmake @@ -1,12 +1,17 @@ # -# Creates forwarding python :term:`pkgutil` infrastructure that "points" -# from the part of the build directory that holds :term:`generated -# code` (python) back to the specified source directories that hold -# :term:`static code`. +# Create forwarding Python :term:`pkgutil` infrastructure in +# buildspace that enables mixing :term:`generated code` in buildspace +# with :term:`static code` from sourcespace within a single Python +# package. # -# In addition, this will provoke that the python distutils' file -# ``setup.py`` is interrogated by catkin and used during -# installation. See :ref:`setup_dot_py_handling`. +# In addition, this will interrogate the Python setup.py file in +# ``${${PROJECT_NAME}_SOURCE_DIR}`` and add the install command of +# distutils/setuputils to the install target. +# +# .. note:: If the project also uses message generation via +# ``generate_messages()`` this function must be called before. +# +# @public # function(catkin_python_setup) if(ARGN) @@ -91,7 +96,7 @@ function(catkin_python_setup) get_filename_component(path ${pkg_dir} PATH) set(PACKAGE_PYTHONPATH ${CMAKE_CURRENT_SOURCE_DIR}/${path}) configure_file(${catkin_EXTRAS_DIR}/templates/__init__.py.in - ${catkin_BUILD_PREFIX}/${PYTHON_INSTALL_DIR}/${pkg}/__init__.py + ${CATKIN_BUILD_PREFIX}/${PYTHON_INSTALL_DIR}/${pkg}/__init__.py @ONLY) endforeach() endif() @@ -104,7 +109,7 @@ function(catkin_python_setup) endif() set(PYTHON_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/${script}) configure_file(${catkin_EXTRAS_DIR}/templates/script.py.in - ${catkin_BUILD_PREFIX}/bin/${name} + ${CATKIN_BUILD_PREFIX}/bin/${name} @ONLY) endforeach() endif() diff --git a/cmake/catkin_stack.cmake b/cmake/catkin_stack.cmake index d15df513b..a043f3a87 100644 --- a/cmake/catkin_stack.cmake +++ b/cmake/catkin_stack.cmake @@ -1,13 +1,21 @@ # -# `Required for all stacks.` +# Process :ref:`stack.xml` from ``CMAKE_CURRENT_SOURCE_DIR`` and +# make several information available to CMake. +# +# .. note:: It must be called once in each stack's CMakeLists.txt, +# before any calls to `catkin_project()`, to ensure that +# auto-generated CMake and pkg-config files contain correct version +# information. +# +# It installs ``stack.xml`` to ``share/${CATKIN_CURRENT_STACK}``. +# +# :outvar CATKIN_CURRENT_STACK: the stack name +# :outvar _VERSION: the version number +# :outvar _MAINTAINER: the name and email of the maintainer(s) +# :outvar _DEPENDS: the build dependencies +# +# @public # -# Reads the :ref:`stack.xml` from the current source dir and makes -# the version number available to cmake via ``stackname_VERSION``; -# does the same for other fields in the `stack.xml`. Also sets -# ``CATKIN_CURRENT_STACK``. You must call `catkin_stack()` once -# in each stack's CMakeLists.txt, before any calls to `catkin_project()`, -# to ensure that auto-generated pkg-config and CMake files get correct -# version information. function(catkin_stack) debug_message(10 "catkin_stack() called in file ${CMAKE_CURRENT_LIST_FILE}") diff --git a/cmake/catkin_workspace.cmake b/cmake/catkin_workspace.cmake index aa846e3a2..2cc103a07 100644 --- a/cmake/catkin_workspace.cmake +++ b/cmake/catkin_workspace.cmake @@ -1,16 +1,19 @@ # -# Called only in catkin's ``toplevel.cmake``, normally symlinked to -# from the workspace level directory (which contains multiple -# stacks). This provokes the traversal of the stack directories -# based on the dependencies specified in the ``build_depends`` field of -# their respective ``stack.xml`` files. +# Search all direct subfolders in the workspace for ``stack.xml`` +# files. Based on the dependencies specified in the +# ``build_depends`` tags it performs a topological sort and calls +# ``add_subdirectory()`` for each directory. +# +# The functions is only called in catkin's ``toplevel.cmake``, which +# is usually symlinked to the workspace root directory (which +# contains multiple stacks). # function(catkin_workspace) debug_message(10 "catkin_workspace() called in file '${CMAKE_CURRENT_LIST_FILE}'") # set global output directories for artifacts and create them if necessary - set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/lib) - set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/lib) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/lib) + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/lib) if(NOT IS_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) file(MAKE_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) endif() @@ -22,7 +25,7 @@ function(catkin_workspace) foreach(workspace ${CATKIN_WORKSPACES}) include_directories(${workspace}/include) endforeach() - include_directories(BEFORE ${catkin_BUILD_PREFIX}/include) + include_directories(BEFORE ${CATKIN_BUILD_PREFIX}/include) set(CATKIN_WHITELIST_STACKS "" CACHE STRING "List of ';' separated stacks to build") set(CATKIN_BLACKLIST_STACKS "" CACHE STRING "List of ';' separated stacks to exclude") diff --git a/cmake/env-hooks/05.catkin-test-results.bat.in b/cmake/env-hooks/05.catkin-test-results.bat.in index 983869e7f..c63b024f9 100644 --- a/cmake/env-hooks/05.catkin-test-results.bat.in +++ b/cmake/env-hooks/05.catkin-test-results.bat.in @@ -1,6 +1,6 @@ REM generated from catkin/cmake/env-hooks/05.catkin-test-results.bat.in -if [@ENV_BUILDSPACE@]==[true] ( +if [@BUILDSPACE@]==[true] ( set CATKIN_TEST_RESULTS_DIR=@CMAKE_BINARY_DIR@/test_results set ROS_TEST_RESULTS_DIR=%CATKIN_TEST_RESULTS_DIR% ) diff --git a/cmake/env-hooks/05.catkin-test-results.sh.in b/cmake/env-hooks/05.catkin-test-results.sh.in index 2ce232781..ffe3449a1 100644 --- a/cmake/env-hooks/05.catkin-test-results.sh.in +++ b/cmake/env-hooks/05.catkin-test-results.sh.in @@ -1,6 +1,6 @@ # generated from catkin/cmake/env-hooks/05.catkin-test-results.sh.in -if @ENV_BUILDSPACE@; then +if @BUILDSPACE@; then export CATKIN_TEST_RESULTS_DIR=@CMAKE_BINARY_DIR@/test_results export ROS_TEST_RESULTS_DIR=$CATKIN_TEST_RESULTS_DIR fi diff --git a/cmake/rosbuild_compat.cmake b/cmake/rosbuild_compat.cmake index 12e1a68f6..ddc137635 100644 --- a/cmake/rosbuild_compat.cmake +++ b/cmake/rosbuild_compat.cmake @@ -66,7 +66,7 @@ function(rosbuild_add_gtest TARGET) message(STATUS " >> Rosbuild-compat: rosbuild_add_gtest ${ARGN}") add_executable(${TARGET} ${catkin_EXTRAS_DIR}/dummy_main.cpp) set_property(TARGET ${TARGET} PROPERTY - RUNTIME_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/bin) + RUNTIME_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/bin) endfunction() function(rosbuild_add_rostest TARGET) @@ -75,6 +75,6 @@ function(rosbuild_add_rostest TARGET) add_executable(rostest_${_testname} ${catkin_EXTRAS_DIR}/dummy_main.cpp) set_property(TARGET rostest_${_testname} PROPERTY - RUNTIME_OUTPUT_DIRECTORY ${catkin_BUILD_PREFIX}/bin) + RUNTIME_OUTPUT_DIRECTORY ${CATKIN_BUILD_PREFIX}/bin) endfunction() diff --git a/cmake/test/gtest.cmake b/cmake/test/gtest.cmake index 1236f5741..9f054edd4 100644 --- a/cmake/test/gtest.cmake +++ b/cmake/test/gtest.cmake @@ -1,46 +1,26 @@ -# -# Copyright (c) 2011, Willow Garage, Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the Willow Garage, Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - # # Add a GTest based test target. -# An executable target is created with all source files, it is linked +# +# An executable target is created with the source files, it is linked # against GTest and added to the set of unit tests. # -# The test can be executed by calling the binary directly or using: -# `` make run_tests_${PROJECT_NAME}_gtest_${target}`` +# .. note:: The test can be executed by calling the binary directly +# or using: ``make run_tests_${PROJECT_NAME}_gtest_${target}`` # -# :param target: the name of the target -# :param source_files: a list of source files used to build the test executable -# :param WORKING_DIRECTORY: the working directory when executing -# the executable. -# :param TIMEOUT: is currently not supported. +# :param target: the target name +# :type target: string +# :param source_files: a list of source files used to build the test +# executable +# :type source_files: list of strings +# :param WORKING_DIRECTORY: the working directory when executing the +# executable +# :type FILE_PREFIX: string +# :param TIMEOUT: currently not supported +# :type FILE_PREFIX: integer # -function(add_gtest target) +# @public +# +function(catkin_add_gtest target) if(NOT GTEST_FOUND) message(STATUS "skipping gtest '${target}' in project '${PROJECT_NAME}'") return() @@ -49,7 +29,7 @@ function(add_gtest target) # XXX look for optional TIMEOUT argument, #2645 parse_arguments(_gtest "TIMEOUT;WORKING_DIRECTORY" "" ${ARGN}) if(_gtest_TIMEOUT) - message(WARNING "TIMEOUT argument to add_gtest() is ignored") + message(WARNING "TIMEOUT argument to catkin_add_gtest() is ignored") endif() # create the executable, with basic + gtest build flags @@ -67,6 +47,11 @@ function(add_gtest target) catkin_run_tests_target("gtest" ${target} "gtest-${target}.xml" COMMAND ${cmd} WORKING_DIRECTORY ${_gtest_WORKING_DIRECTORY}) endfunction() +function(add_gtest target) + message(WARNING "add_gtest() is deprecated, please rename the function call to catkin_add_gtest()") + catkin_add_gtest($ARGN) +endfunction() + if(_CATKIN_GTEST_SRC_FOUND) return() endif() diff --git a/cmake/test/nosetests.cmake b/cmake/test/nosetests.cmake index 8ac076d9d..be2ad9732 100644 --- a/cmake/test/nosetests.cmake +++ b/cmake/test/nosetests.cmake @@ -1,18 +1,26 @@ # -# Add Python nosetests. -# An executable is built with the name of the source file, linked against -# GTest and added to the set of unit tests. +# Add Python nose tests. # -# The test can be executed by calling nosetests directly or using: -# `` make run_tests_${PROJECT_NAME}_nosetests_${dir}`` -# (where slashs in the ``dir`` are replaced with underscores) +# Nose collects tests from the directory ``dir`` automatically. # -# :param dir: a relative or absolute directory to search for nosetests in -# :param WORKING_DIRECTORY: the working directory when executing -# the tests. -# :param TIMEOUT: the timeout for individual tests (default 60s). +# .. note:: The test can be executed by calling ``nosetests`` +# directly or using: +# `` make run_tests_${PROJECT_NAME}_nosetests_${dir}`` +# (where slashes in the ``dir`` are replaced with underscores) # -function(add_nosetests dir) +# :param dir: a relative or absolute directory to search for +# nosetests in +# :type dir: string +# :param WORKING_DIRECTORY: the working directory when executing the +# tests +# :type WORKING_DIRECTORY: string +# :param TIMEOUT: the timeout for individual tests in seconds +# (default: 60) +# :type TIMEOUT: integer +# +# @public +# +function(catkin_add_nosetests dir) if(NOT NOSETESTS) message(STATUS "skipping nosetests(${dir}) in project '${PROJECT_NAME}'") return() @@ -51,6 +59,11 @@ function(add_nosetests dir) catkin_run_tests_target("nosetests" ${output_file_name} "nosetests-${output_file_name}.xml" COMMAND ${cmd} WORKING_DIRECTORY ${_nose_WORKING_DIRECTORY}) endfunction() +function(add_nosetests) + message(WARNING "add_nosetests() is deprecated, please rename the function call to catkin_add_nosetests()") + catkin_add_nosetests(${ARGN}) +endfunction() + find_program(NOSETESTS nosetests) if(NOT nosetests_path) # retry with name including major version number diff --git a/cmake/test/tests.cmake b/cmake/test/tests.cmake index 1034d899a..e614aa0c9 100644 --- a/cmake/test/tests.cmake +++ b/cmake/test/tests.cmake @@ -29,7 +29,15 @@ if(NOT TARGET clean-test-results) add_dependencies(tests clean-test-results) endif() -# all test results go under ${CATKIN_TEST_RESULTS_DIR}/${PROJECT_NAME}/.. +# +# Create a test target, integrate it with the run_tests infrastructure +# and post-process the junit result. +# +# All test results go under ${CATKIN_TEST_RESULTS_DIR}/${PROJECT_NAME}/.. +# +# This function is only used internally by the various +# catkin_add_*test() functions. +# function(catkin_run_tests_target type name xunit_filename) parse_arguments(_testing "COMMAND;WORKING_DIRECTORY" "" ${ARGN}) if(_testing_DEFAULT_ARGS) diff --git a/doc/catkin_migration.rst b/doc/catkin_migration.rst index d3c6404f3..3df5bb971 100644 --- a/doc/catkin_migration.rst +++ b/doc/catkin_migration.rst @@ -29,13 +29,15 @@ Update `CMakeLists.txt`` files Specify ``DESTINATION``, ``ARCHIVE DESTINATION``, ``LIBRARY DESTINATION`` and ``RUNTIME DESTINATION`` as required. -* After create a GTest target using ``catkin_add_gtest(target ...)`` you should test for the existance of the target before trying to use it (i.e. by calling ``target_link_libraries(target ..,)``):: +* Remove manually ``install()`` invocations for ``stack.xml`` and ``manifest.xml`` files (this is handled by catkin automatically). + +* After creating a GTest target using ``catkin_add_gtest(target ...)`` you should test for the existance of the target before trying to use it (i.e. by calling ``target_link_libraries(target ..,)``):: % if(TARGET target) % target_link_libraries(target ...) % endif() - This handles the case gracefully where GTest is not available. + This handles the case gracefully when GTest is not available. CMake extra files ----------------- diff --git a/doc/rosbuild_migration.rst b/doc/rosbuild_migration.rst index 52fd8b707..f4150020b 100644 --- a/doc/rosbuild_migration.rst +++ b/doc/rosbuild_migration.rst @@ -21,8 +21,12 @@ catkin are: 2. Create a top-level ``CMakeLists.txt`` for the stack... 3. For each folder containing a ``manifest.xml`` file: - a. Create a CMake project containing a ``catkin_project(PACKAGE_NAME)`` invocation... - b. Combine ``rosdep`` keys from ``manifest.xml`` files into ``stack.xml`` as ``build_depends`` and ``depends`` keys... + a. Replace the exported explicit compiler and linker flags with a dynamic pkg-config invocation: + + ```` + + b. Create a CMake project containing a ``catkin_project(PACKAGE_NAME)`` invocation... + c. Combine ``rosdep`` keys from ``manifest.xml`` files into ``stack.xml`` as ``build_depends`` and ``depends`` keys... 4. In each ``CMakeLists.txt``: