Skip to content

Commit

Permalink
Improve the generation of config.cmake and version.cmake files
Browse files Browse the repository at this point in the history
Improve the generation of config.cmake and version.cmake files, relocatable via CONFIGURE_PACKAGE_CONFIG_FILE. Upgrades the Travis build farm requirements to Ubuntu Trusty.
  • Loading branch information
jvgomez authored and ahornung committed May 2, 2016
1 parent 0d174e9 commit f68bf52
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 85 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
language: cpp
sudo: required
dist: trusty
compiler:
- gcc
- clang
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libqt4-dev libqt4-opengl-dev libqglviewer-qt4-dev
- sudo apt-get install -qq libqt4-dev libqt4-opengl-dev libqglviewer-dev
before_script:
- mkdir build
- cd build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT( octomap-distribution )

ENABLE_TESTING() # enable CTest environment of subprojects
Expand Down
34 changes: 25 additions & 9 deletions dynamicEDT3D/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT(dynamicEDT3D)

ENABLE_TESTING()
Expand Down Expand Up @@ -96,10 +96,18 @@ ELSE()
ENDIF()
# not used right now (export depends?)
#set(DYNEDT3D_CMAKE_DIR "${PROJECT_BINARY_DIR}")
configure_file(dynamicEDT3DConfig.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig.cmake" @ONLY)
configure_file(dynamicEDT3DConfig-version.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig-version.cmake" @ONLY)
include(CMakePackageConfigHelpers)

CONFIGURE_PACKAGE_CONFIG_FILE(
dynamicEDT3DConfig.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig.cmake"
PATH_VARS DYNAMICEDT3D_INCLUDE_DIRS DYNAMICEDT3D_LIB_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dynamicEDT3D)

WRITE_BASIC_PACKAGE_VERSION_FILE(
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3DConfig-version.cmake"
VERSION ${DYNAMICEDT3D_VERSION}
COMPATIBILITY AnyNewerVersion)

# Install the export set for use with the install-tree
#install(EXPORT FooBarLibraryDepends DESTINATION
Expand All @@ -111,10 +119,18 @@ configure_file(dynamicEDT3DConfig-version.cmake.in
set(DYNAMICEDT3D_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
set(DYNAMICEDT3D_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
#set(DYNAMICEDT3D_CMAKE_DIR "${INSTALL_DATA_DIR}/FooBar/CMake")
configure_file(dynamicEDT3DConfig.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake" @ONLY)
configure_file(dynamicEDT3DConfig-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake" @ONLY)

CONFIGURE_PACKAGE_CONFIG_FILE(
dynamicEDT3DConfig.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake"
PATH_VARS DYNAMICEDT3D_INCLUDE_DIRS DYNAMICEDT3D_LIB_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/dynamicEDT3D)

WRITE_BASIC_PACKAGE_VERSION_FILE(
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake"
VERSION ${DYNAMICEDT3D_VERSION}
COMPATIBILITY AnyNewerVersion)

install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake"
Expand Down
11 changes: 0 additions & 11 deletions dynamicEDT3D/dynamicEDT3DConfig-version.cmake.in

This file was deleted.

15 changes: 8 additions & 7 deletions dynamicEDT3D/dynamicEDT3DConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# - Config file for the dynamicEDT3D package
# (example from http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file)
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
Expand All @@ -12,12 +11,14 @@
# DYNAMICEDT3D_INCLUDE_DIRS - include directories for dynamicEDT3D
# DYNAMICEDT3D_LIBRARY_DIRS - library directories for dynamicEDT3D (normally not used!)
# DYNAMICEDT3D_LIBRARIES - libraries to link against


@PACKAGE_INIT@

# Tell the user project where to find our headers and libraries
set(DYNAMICEDT3D_INCLUDE_DIRS "@DYNAMICEDT3D_INCLUDE_DIRS@")
set(DYNAMICEDT3D_LIBRARY_DIRS "@DYNAMICEDT3D_LIB_DIR@")
set(DYNAMICEDT3D_INCLUDE_DIRS "@PACKAGE_DYNAMICEDT3D_INCLUDE_DIRS@")
set(DYNAMICEDT3D_LIBRARY_DIRS "@PACKAGE_DYNAMICEDT3D_LIB_DIR@")

# Our library dependencies (contains definitions for IMPORTED targets)
# include("@FOOBAR_CMAKE_DIR@/FooBarLibraryDepends.cmake")
set(DYNAMICEDT3D_LIBRARIES "@DYNAMICEDT3D_LIB_DIR@/@DYNAMICEDT3D_LIBRARY@")

set(DYNAMICEDT3D_LIBRARIES "@PACKAGE_DYNAMICEDT3D_LIB_DIR@/@DYNAMICEDT3D_LIBRARY@")
32 changes: 23 additions & 9 deletions octomap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT( octomap )

ENABLE_TESTING()
Expand Down Expand Up @@ -103,22 +103,36 @@ ENDIF()

# not used right now (export depends?)
#set(OCTOMAP_CMAKE_DIR "${PROJECT_BINARY_DIR}")
configure_file(octomap-config.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-config.cmake" @ONLY)
configure_file(octomap-config-version.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-config-version.cmake" @ONLY)
include(CMakePackageConfigHelpers)

CONFIGURE_PACKAGE_CONFIG_FILE(
octomap-config.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-config.cmake"
PATH_VARS OCTOMAP_INCLUDE_DIRS OCTOMAP_LIB_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/octomap)

WRITE_BASIC_PACKAGE_VERSION_FILE(
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octomap/octomap-config-version.cmake"
VERSION ${OCTOMAP_VERSION}
COMPATIBILITY AnyNewerVersion)

# Create a octomap-config.cmake file for the use from the install tree
# and install it
set(OCTOMAP_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
set(OCTOMAP_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
#set(OCTOMAP_CMAKE_DIR "${INSTALL_DATA_DIR}/FooBar/CMake")

configure_file(octomap-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake" @ONLY)
configure_file(octomap-config-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake" @ONLY)
CONFIGURE_PACKAGE_CONFIG_FILE(
octomap-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake"
PATH_VARS OCTOMAP_INCLUDE_DIRS OCTOMAP_LIB_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/octomap)

WRITE_BASIC_PACKAGE_VERSION_FILE(
${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake
VERSION ${OCTOMAP_VERSION}
COMPATIBILITY AnyNewerVersion)

install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake"
Expand Down
11 changes: 0 additions & 11 deletions octomap/octomap-config-version.cmake.in

This file was deleted.

14 changes: 6 additions & 8 deletions octomap/octomap-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,16 @@
# LINK_DIRECTORIES with this path is NOT needed.
# - OCTOMAP_INCLUDE_DIRS : The OctoMap include directories.
#
# Based on the example CMake Tutorial
# http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
# and OpenCVConfig.cmake.in from OpenCV
# ===================================================================================


set(OCTOMAP_INCLUDE_DIRS "@OCTOMAP_INCLUDE_DIRS@")
set(OCTOMAP_LIBRARY_DIRS "@OCTOMAP_LIB_DIR@")
@PACKAGE_INIT@

set(OCTOMAP_INCLUDE_DIRS "@PACKAGE_OCTOMAP_INCLUDE_DIRS@")
set(OCTOMAP_LIBRARY_DIRS "@PACKAGE_OCTOMAP_LIB_DIR@")


# Set library names
set(OCTOMAP_LIBRARIES
"@OCTOMAP_LIB_DIR@/@OCTOMAP_LIBRARY@"
"@OCTOMAP_LIB_DIR@/@OCTOMATH_LIBRARY@"
"@PACKAGE_OCTOMAP_LIB_DIR@/@OCTOMAP_LIBRARY@"
"@PACKAGE_OCTOMAP_LIB_DIR@/@OCTOMATH_LIBRARY@"
)
41 changes: 29 additions & 12 deletions octovis/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8)
PROJECT( octovis )

# # version (e.g. for packaging)
Expand Down Expand Up @@ -61,6 +61,7 @@ SET( BUILD_VIEWER 0)
# Look for required libraries:
FIND_PACKAGE(OpenGL)
FIND_PACKAGE(Qt4)

IF (OpenGL-NOTFOUND OR Qt4-NOTFOUND)
MESSAGE ( "OpenGL and QT4 are required for octovis but could not be found.")
ELSE()
Expand All @@ -84,7 +85,7 @@ IF(BUILD_VIEWER)
INCLUDE( CMakeLists_src.txt )

# Create an octovis-config.cmake file for the use from the build tree
set(OCTOVIS_INCLUDE_DIR "${INCLUDE_DIRS}")
set(OCTOVIS_INCLUDE_DIRS "${INCLUDE_DIRS}")
set(OCTOVIS_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
# Set library names as absolute paths
# Windows, spec. MSVC requires the .lib suffix for imported libs
Expand All @@ -98,28 +99,44 @@ IF(BUILD_VIEWER)
)
ENDIF()

include(CMakePackageConfigHelpers)

CONFIGURE_PACKAGE_CONFIG_FILE(
octovis-config.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octovis/octovis-config.cmake"
PATH_VARS OCTOVIS_INCLUDE_DIRS OCTOVIS_LIB_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/octovis)

WRITE_BASIC_PACKAGE_VERSION_FILE(
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octovis/octovis-config-version.cmake"
VERSION ${OCTOVIS_VERSION}
COMPATIBILITY AnyNewerVersion)

# not used right now (export depends?)
#set(OCTOMAP_CMAKE_DIR "${PROJECT_BINARY_DIR}")
configure_file(octovis-config.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octovis/octovis-config.cmake" @ONLY)
configure_file(octovis-config-version.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/octovis/octovis-config-version.cmake" @ONLY)

# Create a octovis-config.cmake file for the use from the install tree
# and install it
set(OCTOVIS_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
set(OCTOVIS_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib")
#set(OCTOMAP_CMAKE_DIR "${INSTALL_DATA_DIR}/FooBar/CMake")
configure_file(octovis-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake" @ONLY)
configure_file(octovis-config-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake" @ONLY)

CONFIGURE_PACKAGE_CONFIG_FILE(
octovis-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake"
PATH_VARS OCTOVIS_INCLUDE_DIRS OCTOVIS_LIB_DIR
INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX}/share/octovis)

WRITE_BASIC_PACKAGE_VERSION_FILE(
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake"
VERSION ${OCTOVIS_VERSION}
COMPATIBILITY AnyNewerVersion)

install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake"
DESTINATION share/octovis/)



# #installation:
# # store all header files to install:
file(GLOB octovis_HDRS *.h *.hxx *.hpp)
Expand Down
11 changes: 0 additions & 11 deletions octovis/octovis-config-version.cmake.in

This file was deleted.

10 changes: 5 additions & 5 deletions octovis/octovis-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# - Config file for the OctoMap package
# (example from http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file)
# It defines the following variables
# OCTOVIS_INCLUDE_DIRS - include directories for OctoMap viewer
# OCTOVIS_LIBRARY_DIRS - library directories for OctoMap viewer
# OCTOVIS_LIBRARIES - libraries to link against

set(OCTOVIS_INCLUDE_DIRS "@QGLViewer_INCLUDE_DIR@" "@OCTOVIS_INCLUDE_DIR@")
set(OCTOVIS_LIBRARY_DIRS "@QGLViewer_LIBRARY_DIR@" "@OCTOVIS_LIB_DIR@")
@PACKAGE_INIT@

set(OCTOVIS_INCLUDE_DIRS "@QGLViewer_INCLUDE_DIR@" "@PACKAGE_OCTOVIS_INCLUDE_DIRS@")
set(OCTOVIS_LIBRARY_DIRS "@QGLViewer_LIBRARY_DIR@" "@PACKAGE_OCTOVIS_LIB_DIR@")


# Set library names as absolute paths:
set(OCTOVIS_LIBRARIES
"@QGLViewer_LIBRARIES@"
"@QT_LIBRARIES@"
"@OCTOVIS_LIB_DIR@/@OCTOVIS_LIBRARY@"
"@PACKAGE_OCTOVIS_LIB_DIR@/@OCTOVIS_LIBRARY@"
)

0 comments on commit f68bf52

Please sign in to comment.