Skip to content

Commit

Permalink
more CMake tweaks: uninstall target, build static and dynamic libs
Browse files Browse the repository at this point in the history
  • Loading branch information
Armin Hornung committed Jul 26, 2011
1 parent 7684acb commit 837116a
Show file tree
Hide file tree
Showing 8 changed files with 72 additions and 29 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ install(FILES ${octomap_HDRS} DESTINATION include/octomap)
file(GLOB octomap_math_HDRS ${CMAKE_SOURCE_DIR}/include/octomap/math/*.h)
install(FILES ${octomap_math_HDRS} DESTINATION include/octomap/math)

# uninstall target
configure_file(
"CMakeModules/CMakeUninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)


# Export the package for use from the build-tree
# (this registers the build-tree with a global CMake-registry)
export(PACKAGE octomap)
Expand Down Expand Up @@ -94,7 +104,13 @@ install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/octomap-config-version.cmake"
DESTINATION lib/cmake/octomap/)


# Write pkgconfig-file:
include(CMakeModules/InstallPkgConfigFile.cmake)
install_pkg_config_file(octomap
CFLAGS
LIBS -loctomap -loctomath
REQUIRES
VERSION ${OCTOMAP_MAJOR_VERSION}.${OCTOMAP_MINOR_VERSION}.${OCTOMAP_PATCH_VERSION})

# Documentation
FIND_PACKAGE(Doxygen)
Expand Down
22 changes: 22 additions & 0 deletions CMakeModules/CMakeUninstall.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")

file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
list(REVERSE files)
foreach (file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if (EXISTS "$ENV{DESTDIR}${file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
OUTPUT_VARIABLE rm_out
RESULT_VARIABLE rm_retval
)
if(NOT ${rm_retval} EQUAL 0)
message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
endif (NOT ${rm_retval} EQUAL 0)
else (EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
endif (EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)
10 changes: 2 additions & 8 deletions CMakeModules/CPackSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,8 @@ SET(CPACK_PACKAGE_CONTACT "K.M. Wurm and A. Hornung")
SET(CPACK_PACKAGE_VENDOR "University of Freiburg")
SET(CPACK_GENERATOR "DEB")
SET(CPACK_SOURCE_GENERATOR "TGZ")


include(CMakeModules/InstallPkgConfigFile.cmake)
install_pkg_config_file(octomap
CFLAGS
LIBS -loctomap -loctomath
REQUIRES
VERSION ${OCTOMAP_MAJOR_VERSION}.${OCTOMAP_MINOR_VERSION}.${OCTOMAP_PATCH_VERSION})
SET(CPACK_SOURCE_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

# This must always be last statement!
INCLUDE(CPack)
Expand Down
2 changes: 1 addition & 1 deletion include/octomap/OccupancyOcTreeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ namespace octomap {


protected:

bool use_change_detection;
bool use_bbx_limit; ///< use bounding box for queries (needs to be set)?
point3d bbx_min;
point3d bbx_max;
Expand Down
9 changes: 4 additions & 5 deletions include/octomap/OccupancyOcTreeBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace octomap {
void OccupancyOcTreeBase<NODE>::computeUpdate(const Pointcloud& scan, const octomap::point3d& origin,
KeySet& free_cells,
KeySet& occupied_cells,
double maxrange) {
double maxrange){

for (Pointcloud::const_iterator point_it = scan.begin(); point_it != scan.end(); point_it++) {
const point3d& p = *point_it;
Expand Down Expand Up @@ -223,10 +223,9 @@ namespace octomap {
NODE* OccupancyOcTreeBase<NODE>::updateNode(const OcTreeKey& key, bool occupied, bool dirty) {

NODE* leaf = this->search(key);
if (leaf) {
if ((isNodeAtThreshold(leaf)) && (isNodeOccupied(leaf) == occupied)) {
return leaf;
}
// no change: node already at threshold
if (leaf && (isNodeAtThreshold(leaf)) && (isNodeOccupied(leaf) == occupied)) {
return leaf;
}
return updateNodeRecurs(this->itsRoot, false, key, 0, occupied, dirty);
}
Expand Down
11 changes: 9 additions & 2 deletions src/octomap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ SET (octomap_SRCS
OcTreeLUT.cpp
)

ADD_LIBRARY( octomap ${octomap_SRCS})
# dynamic and static libs, see CMake FAQ:
ADD_LIBRARY( octomap SHARED ${octomap_SRCS})
ADD_LIBRARY( octomap-static STATIC ${octomap_SRCS})
SET_TARGET_PROPERTIES(octomap-static PROPERTIES OUTPUT_NAME "octomap")
SET_TARGET_PROPERTIES(octomap-static PROPERTIES PREFIX "lib")


# Link in ROS libs e.g. for logging output if needed:
if(WITH_ROS)
Expand Down Expand Up @@ -54,7 +59,9 @@ TARGET_LINK_LIBRARIES(test_lut octomap)
# file(GLOB octomap_impl_HDRS *.h *.hxx *.hpp)
# install(FILES ${octomap_impl_HDRS} DESTINATION include/octomap)

install(TARGETS octomap
install(TARGETS
octomap
octomap-static
graph2tree
log2graph
binvox2bt
Expand Down
12 changes: 5 additions & 7 deletions src/octomap/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ SET (octomath_SRCS
)


ADD_LIBRARY( octomath ${octomath_SRCS})
ADD_LIBRARY( octomath SHARED ${octomath_SRCS})
ADD_LIBRARY( octomath-static STATIC ${octomath_SRCS})
SET_TARGET_PROPERTIES(octomath-static PROPERTIES OUTPUT_NAME "octomath")
SET_TARGET_PROPERTIES(octomath-static PROPERTIES PREFIX "lib")

# store all header files to install:
file(GLOB octomath_HDRS *.h *.hxx *.hpp)

install(FILES ${octomath_HDRS} DESTINATION include/octomath)

install(TARGETS octomath ${INSTALL_TARGETS_DEFAULT_ARGS})
install(TARGETS octomath octomath-static ${INSTALL_TARGETS_DEFAULT_ARGS})
17 changes: 12 additions & 5 deletions src/octovis/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,15 @@ INCLUDE_DIRECTORIES(
)

# Library target
add_library(octovis_library ${viewerlib_SRCS})
target_link_libraries(octovis_library)
set_target_properties(octovis_library PROPERTIES OUTPUT_NAME octovis)
add_library(octovis-static STATIC ${viewerlib_SRCS})
target_link_libraries(octovis-static)
set_target_properties(octovis-static PROPERTIES OUTPUT_NAME octovis)
SET_TARGET_PROPERTIES(octovis-static PROPERTIES PREFIX "lib")

add_library(octovis-shared SHARED ${viewerlib_SRCS})
target_link_libraries(octovis-shared)
set_target_properties(octovis-shared PROPERTIES OUTPUT_NAME octovis)


# Now add these generated files to the ADD_EXECUTABLE step
# If this is NOT done, then the ui_*.h files will not be generated
Expand All @@ -81,7 +87,7 @@ target_link_libraries(octovis
${QGLViewer_LIBRARIES}
${QT_LIBRARIES}
octomap
octovis_library
octovis-shared
)

# special handling of MacOS X:
Expand All @@ -100,6 +106,7 @@ file(GLOB octovis_HDRS *.h *.hxx *.hpp)
install(FILES ${octovis_HDRS} DESTINATION include/octovis)

install(TARGETS octovis
octovis_library
octovis-static
octovis-shared
${INSTALL_TARGETS_DEFAULT_ARGS}
)

0 comments on commit 837116a

Please sign in to comment.