Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sma/rework cmake module #57

Open
wants to merge 4 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ ENABLE_TESTING() # enable CTest environment of subprojects
ADD_SUBDIRECTORY( octomap )
ADD_SUBDIRECTORY( octovis )
ADD_SUBDIRECTORY( dynamicEDT3D )



37 changes: 21 additions & 16 deletions dynamicEDT3D/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,35 +66,40 @@ install(FILES ${dynamicEDT3D_HDRS} DESTINATION include/dynamicEDT3D)
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE dynamicEDT3D)
# Create a dynamicEDT3DConfig.cmake file for the use from the build tree

# Create a dynamicEDT3D-config.cmake file for the use from the build tree
set(DYNAMICEDT3D_INCLUDE_DIRS "${INCLUDE_DIRS}")
set(DYNAMICEDT3D_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
# 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)
configure_file(dynamicEDT3D-config.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3D-config.cmake" @ONLY)
configure_file(dynamicEDT3D-config-version.cmake.in
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/cmake/dynamicEDT3D/dynamicEDT3D-config-version.cmake" @ONLY)

# Install the export set for use with the install-tree
#install(EXPORT FooBarLibraryDepends DESTINATION
# "${INSTALL_DATA_DIR}/FooBar/CMake"
# COMPONENT dev)
# Create a dynamicEDT3DConfig.cmake file for the use from the install tree

# Create a dynamicEDT3D-config.cmake file for the use from the install tree
# and install it
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_file(dynamicEDT3D-config.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config.cmake" @ONLY)
configure_file(dynamicEDT3D-config-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config-version.cmake" @ONLY)
IF(DEFINED NO_ABSOLUTE_PATH_IN_MODULE AND NO_ABSOLUTE_PATH_IN_MODULE)
set(DYNAMICEDT3D_MODULE_FILE "dynamicEDT3D-config.cmake")
ELSE()
set(DYNAMICEDT3D_MODULE_FILE "${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config.cmake" )
ENDIF()
install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3DConfig-version.cmake"
DESTINATION lib/cmake/dynamicEDT3D/)
"${PROJECT_BINARY_DIR}/InstallFiles/dynamicEDT3D-config-version.cmake"
"${DYNAMICEDT3D_MODULE_FILE}"
DESTINATION share/dynamicEDT3D/)

# Write pkgconfig-file:
include(InstallPkgConfigFile)
Expand All @@ -105,7 +110,7 @@ install_pkg_config_file(dynamicEDT3D
VERSION ${DYNAMICEDT3D_MAJOR_VERSION}.${DYNAMICEDT3D_MINOR_VERSION}.${DYNAMICEDT3D_PATCH_VERSION})


# Documentation
# Documentation
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
ADD_CUSTOM_TARGET(docs_dynamicEDT3D ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dynamicEDT3D.dox
Expand Down
19 changes: 19 additions & 0 deletions dynamicEDT3D/dynamicEDT3D-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# - 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
# OCTOMAP_INCLUDE_DIRS - include directories for OctoMap
# OCTOMAP_LIBRARIES - libraries to link against

set(DYNAMICEDT3D_INCLUDE_DIRS)
set(DYNAMICEDT3D_INCLUDE DYNAMICEDT3D_INCLUDE-NOTFOUND)
find_path(DYNAMICEDT3D_INCLUDE dynamicEDT3D/dynamicEDT3D.h)
if(DYNAMICEDT3D_INCLUDE)
list(APPEND DYNAMICEDT3D_INCLUDE_DIRS ${DYNAMICEDT3D_INCLUDE})
endif()

set(DYNAMICEDT3D_LIBRARIES)
set(DYNAMICEDT3D_LIB DYNAMICEDT3D_LIB-NOTFOUND)
find_library(DYNAMICEDT3D_LIB dynamicedt3d)
if(DYNAMICEDT3D_LIB)
list(APPEND DYNAMICEDT3D_LIBRARIES ${DYNAMICEDT3D_LIB})
endif()
15 changes: 10 additions & 5 deletions octomap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ add_custom_target(uninstall
# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE octomap)

# Create a octomap-config.cmake file for the use from the build tree
set(OCTOMAP_INCLUDE_DIRS "${INCLUDE_DIRS}")
set(OCTOMAP_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
Expand All @@ -88,7 +88,7 @@ configure_file(octomap-config-version.cmake.in
#install(EXPORT FooBarLibraryDepends DESTINATION
# "${INSTALL_DATA_DIR}/FooBar/CMake"
# COMPONENT dev)

# Create a octomap-config.cmake file for the use from the install tree
# and install it
set(OCTOMAP_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/include")
Expand All @@ -98,9 +98,14 @@ 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)
IF(DEFINED NO_ABSOLUTE_PATH_IN_MODULE AND NO_ABSOLUTE_PATH_IN_MODULE)
set(OCTOMAP_MODULE_FILE "octomap-config.cmake")
ELSE()
set(OCTOMAP_MODULE_FILE "${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake" )
ENDIF()
install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake"
"${OCTOMAP_MODULE_FILE}"
DESTINATION share/octomap/)

# Write pkgconfig-file:
Expand All @@ -111,7 +116,7 @@ install_pkg_config_file(octomap
REQUIRES
VERSION ${OCTOMAP_VERSION})

# Documentation
# Documentation
FIND_PACKAGE(Doxygen)
IF(DOXYGEN_FOUND)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/octomap.dox.in ${CMAKE_CURRENT_BINARY_DIR}/octomap.dox @ONLY)
Expand Down
41 changes: 41 additions & 0 deletions octomap/octomap-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# ===================================================================================
# The OctoMap CMake configuration file
#
# ** File generated automatically, do not modify **
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# FIND_PACKAGE(octomap REQUIRED )
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${OCTOMAP_LIBRARIES})
#
# This file will define the following variables:
# - OCTOMAP_LIBRARIES : The list of libraries to links against.
# - OCTOMAP_LIBRARY_DIRS : The directory where lib files are. Calling
# LINK_DIRECTORIES with this path is NOT needed.
# - OCTOMAP_INCLUDE_DIRS : The OpenCV 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)
set(OCTOMAP_INCLUDE OCTOMAP_INCLUDE-NOTFOUND)
find_path(OCTOMAP_INCLUDE octomap/octomap.h)
if(OCTOMAP_INCLUDE)
list(APPEND OCTOMAP_INCLUDE_DIRS ${OCTOMAP_INCLUDE})
endif()

set(OCTOMAP_LIBRARIES)
set(OCTOMAP_LIB OCTOMAP_LIB-NOTFOUND)
find_library(OCTOMAP_LIB octomap)
if(OCTOMAP_LIB)
list(APPEND OCTOMAP_LIBRARIES ${OCTOMAP_LIB})
endif()

set(OCTOMATH_LIB OCTOMATH_LIB-NOTFOUND)
find_library(OCTOMATH_LIB octomath)
if(OCTOMATH_LIB)
list(APPEND OCTOMAP_LIBRARIES ${OCTOMATH_LIB})
endif()
31 changes: 18 additions & 13 deletions octovis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ set(INSTALL_TARGETS_DEFAULT_ARGS
ARCHIVE DESTINATION lib
)

# Builds the "octovis" viewer based on OpenGL and
# Builds the "octovis" viewer based on OpenGL and
# libQGLViewer, if dependencies available
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.")
IF (OpenGL-NOTFOUND OR Qt4-NOTFOUND)
MESSAGE ( "OpenGL and QT4 are required for octovis but could not be found.")
ELSE()
FIND_PACKAGE(QGLViewer)
IF(QGLViewer_FOUND)
Expand All @@ -70,12 +70,12 @@ ENDIF()
IF(BUILD_VIEWER)
MESSAGE(STATUS "\n")
MESSAGE(STATUS "viewer octovis will be built")

set(INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include")
INCLUDE_DIRECTORIES(${INCLUDE_DIRS})

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_LIB_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}")
Expand All @@ -84,8 +84,8 @@ IF(BUILD_VIEWER)
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)
"${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")
Expand All @@ -95,20 +95,25 @@ IF(BUILD_VIEWER)
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake" @ONLY)
configure_file(octovis-config-version.cmake.in
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake" @ONLY)
IF(DEFINED NO_ABSOLUTE_PATH_IN_MODULE AND NO_ABSOLUTE_PATH_IN_MODULE)
set(OCTOVIS_MODULE_FILE "octovis-config.cmake")
ELSE()
set(OCTOVIS_MODULE_FILE "${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake" )
ENDIF()
install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/octovis-config-version.cmake"
"${OCTOVIS_MODULE_FILE}"
DESTINATION share/octovis/)


# #installation:
# # store all header files to install:
file(GLOB octovis_HDRS *.h *.hxx *.hpp)
install(FILES ${octovis_HDRS} DESTINATION include/octovis)

# Install catkin package.xml
install(FILES package.xml DESTINATION share/octovis)

ELSE()
MESSAGE ( "Unfortunately, the viewer (octovis) can not be built because some requirements are missing.")
MESSAGE ( "This will not affect the compilation of the stand-alone library and tools (octomap)")
Expand Down
24 changes: 24 additions & 0 deletions octovis/octovis-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# - 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_LIBRARIES - libraries to link against

find_package(OCTOMAP)

set(QGLViewer_LIB QGLViewer_LIB-NOTFOUND)
find_library(QGLViewer_LIB QGLViewer)
if(NOT QGLViewer_LIB)
message(FATAL "Could not find QGLViewer")
endif()

find_package(Qt4 COMPONENTS QTCORE QTGUI QTOPENGL)

set(OCTOVIS_INCLUDE_DIRS)
set(OCTOVIS_LIBRARIES)

list(APPEND OCTOVIS_INCLUDE_DIRS ${OCTOMAP_INCLUDE}
${QT_QTCORE_INCLUDE_DIR} ${QT_QTGUI_INCLUDE_DIR} ${QT_QTOPENGL_INCLUDE_DIR})

list(APPEND OCTOVIS_LIBRARIES ${OCTOMAP_LIB} ${QGLViewer_LIB}
${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTOPENGL_LIBRARY})