Skip to content

Commit

Permalink
Add CPack config for DEB package
Browse files Browse the repository at this point in the history
  • Loading branch information
RainerKuemmerle committed Aug 3, 2024
1 parent fa8095b commit d8937c2
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment ta

project(g2o)

include(CPack)
include(GNUInstallDirs)

# The library prefix
Expand Down Expand Up @@ -465,6 +464,11 @@ install(
NAMESPACE "${G2O_NAMESPACE}"
DESTINATION "${G2O_CONFIG_INSTALL_DIR}")

option(G2O_BUILD_PACKAGE "Include package build config for cpack" OFF)
if(G2O_BUILD_PACKAGE)
include(Packaging)
endif()

# Include the subdirectories
add_subdirectory(g2o)

Expand Down
25 changes: 25 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// g2o - General Graph Optimization
// Copyright (C) 2011 R. Kuemmerle, G. Grisetti, W. Burgard
// 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.
//
// 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
// HOLDER 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.
54 changes: 54 additions & 0 deletions cmake_modules/Packaging.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# RPATH setup
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
endif()

# helper for splitting version string
macro(version_split version_str major minor patch)
string(REGEX REPLACE "([0-9]+).[0-9]+.[0-9]+" "\\1" ${major} ${version_str})
string(REGEX REPLACE "[0-9]+.([0-9]+).[0-9]+" "\\1" ${minor} ${version_str})
string(REGEX REPLACE "[0-9]+.[0-9]+.([0-9]+)" "\\1" ${patch} ${version_str})
endmacro()

version_split(${G2O_VERSION} g2o_major g2o_minor g2o_patch)

set(CPACK_PACKAGE_NAME ${PROJECT_NAME}
CACHE STRING "g2o"
)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "g2o: General Graph Optimization" CACHE
STRING "g2o is an open-source C++ framework for optimizing graph-based
nonlinear error functions. g2o has been designed to be easily extensible to a
wide range of problems and a new problem typically can be specified in a few
lines of code. The current implementation provides solutions to several
variants of SLAM and BA."
)

set(CPACK_VERBATIM_VARIABLES YES)

set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
SET(CPACK_OUTPUT_FILE_PREFIX "${PROJECT_BINARY_DIR}/_packages")

set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_SOURCE_DIR}/cmake_modules/PackagingConfig.cmake)
set(CPACK_STRIP_FILES YES)

set(CPACK_PACKAGE_VERSION_MAJOR ${g2o_major})
set(CPACK_PACKAGE_VERSION_MINOR ${g2o_minor})
set(CPACK_PACKAGE_VERSION_PATCH ${g2o_patch})

set(CPACK_PACKAGE_CONTACT "Rainer Kuemmerle <[email protected]>")

set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")

set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
set(CPACK_DEB_COMPONENT_INSTALL YES)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS YES)
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS "${g2o_LIBRARY_OUTPUT_DIRECTORY}")

include(CPack)
1 change: 1 addition & 0 deletions todo.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[ ] update py_base_vertex/edge to map now common methods
[ ] Use FakeDependency in Traits
[ ] wrap abstract graph to python and update save wrapper
[x] CPack config
[x] Create parameter type for ParameterCamera to support load/save
[x] Refactor Data container. Can it be a container instead of linked list?
[x] EdgeSE2TwoPointsXY, EdgeSE2PointXYCalib can be fixed size edges -> IO test
Expand Down

0 comments on commit d8937c2

Please sign in to comment.