Skip to content

Commit

Permalink
fix problem with libnabo linking
Browse files Browse the repository at this point in the history
  • Loading branch information
pomerlef committed Dec 4, 2014
1 parent 847c9c6 commit 790f2b5
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 15 deletions.
77 changes: 62 additions & 15 deletions CMakeLists.txt
Expand Up @@ -34,6 +34,31 @@ if( BUILD_32 )
SET(CMAKE_CXX_FLAGS "-m32")
endif( BUILD_32 )

# Ensure proper build type
if (NOT CMAKE_BUILD_TYPE)
message("-- No build type specified; defaulting to CMAKE_BUILD_TYPE=Release.")
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
else (NOT CMAKE_BUILD_TYPE)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
message("\n=================================================================================")
message("\n-- Build type: Debug. Performance will be terrible!")
message("-- Add -DCMAKE_BUILD_TYPE=Release to the CMake command line to get an optimized build.")
message("\n=================================================================================")
endif (CMAKE_BUILD_TYPE STREQUAL "Debug")
endif (NOT CMAKE_BUILD_TYPE)


#================= extra building definitions ==============================
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-O3)
endif(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")

# For Windows
if( MSVC ) # VS2012 does not support tuples correctly yet
add_definitions( /D _VARIADIC_MAX=10 )
endif()

#======================= installation =====================================

Expand Down Expand Up @@ -88,7 +113,7 @@ find_path(EIGEN_INCLUDE_DIR Eigen/Core
# nabo
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${LIBNABO_INSTALL_DIR}/share/libnabo/cmake/")
find_package(libnabo)
include(libnaboConfig)
#include(libnaboConfig)
include_directories(${libnabo_INCLUDE_DIRS})

# optionally, look for OpenCL library
Expand Down Expand Up @@ -142,7 +167,7 @@ if (POSIX_TIMERS AND NOT APPLE)
endif (POSIX_TIMERS AND NOT APPLE)

# include all libs so far
include_directories(${CMAKE_SOURCE_DIR} ${EIGEN_INCLUDE_DIR} ${NABO_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR} ${EIGEN_INCLUDE_DIR} ${Boost_INCLUDE_DIRS})

add_definitions(-Wall)

Expand Down Expand Up @@ -220,50 +245,72 @@ add_subdirectory(evaluations)
enable_testing()
add_subdirectory(utest)

#=============================================
# to allow find_package() on pointmatcher
#=============================================
#=================== allow find_package() =========================
#
# the following case be used in an external project requiring libnabo:
# ...
# find_package(libpointmatcher)
# include_directories(${libpointmatcher_INCLUDE_DIRS})
# target_link_libraries(executableName ${libpointmatcher_LIBRARIES})
# ...

# 1- local build #

# Register the local build in case one doesn't use "make install"
export(PACKAGE libpointmatcher)

file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INSTALL_INCLUDE_DIR}")

# Create the libpointmatcherConfig.cmake and libpointmatcherConfigVersion files
file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}"
"${INSTALL_INCLUDE_DIR}")
# ... for the build tree

# Create variable for the local build tree
get_property(CONF_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)

# Create variable with the library location
get_target_property(POINTMATCHER_LIB pointmatcher LOCATION)

# Configure config file for local build tree
configure_file(libpointmatcherConfig.cmake.in
"${PROJECT_BINARY_DIR}/libpointmatcherConfig.cmake" @ONLY)

# Change variables for the install tree
# 2- installation build #

# Change the include location for the case of an install location
set(CONF_INCLUDE_DIRS ${INSTALL_INCLUDE_DIR} ${CONF_INCLUDE_DIRS} )

#FIXME: this will only be applied to installed files. Confirm that we want that.
# gather all the includes but remove ones in the source tree
# because we added an include for the local yaml-cpp-pm we should also remove it
list(REMOVE_ITEM CONF_INCLUDE_DIRS ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/contrib/yaml-cpp-pm/include)

# Change the library location for an install location
get_filename_component(POINTMATCHER_LIB_NAME ${POINTMATCHER_LIB} NAME)
set(POINTMATCHER_LIB ${INSTALL_LIB_DIR}/${POINTMATCHER_LIB_NAME})

# We put the generated file for installation in a different repository (i.e., ./CMakeFiles/)
configure_file(libpointmatcherConfig.cmake.in
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libpointmatcherConfig.cmake" @ONLY)

# Generate cmake for versionning
# The same versioning file can be used for both cases
configure_file(libpointmatcherConfigVersion.cmake.in
"${PROJECT_BINARY_DIR}/libpointmatcherConfigVersion.cmake" @ONLY)


# Install the libpointmatcherConfig.cmake and libpointmatcherConfigVersion.cmake
install(FILES
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libpointmatcherConfig.cmake"
"${PROJECT_BINARY_DIR}/libpointmatcherConfigVersion.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)

install (FILES "${PROJECT_BINARY_DIR}/libpointmatcherConfig.cmake" DESTINATION "share/${PROJECT_NAME}/cmake/")
# TODO: confirm that the following line is useless

This comment has been minimized.

Copy link
@peci1

peci1 Jan 16, 2015

Contributor

It is actually essential for us at TRADR project :) Please, uncomment it ;)

This comment has been minimized.

Copy link
@pomerlef

pomerlef Feb 20, 2015

Author Collaborator

It's back in the recent commit. I would prefer to not have any specific installation per projects. Would it be possible to make it standart?

This comment has been minimized.

Copy link
@peci1

peci1 Feb 24, 2015

Contributor

Thanks ;) Actually, it's not our specific use on TRADR. It's ROS (catkin) what seeks for the cmake file in the share/libpointmatcher/cmake directory. So IMHO this line is essential to keep your library compatible with ROS. Correct me if I'm mistaken.

#install (FILES "${PROJECT_BINARY_DIR}/libpointmatcherConfig.cmake" DESTINATION "share/${PROJECT_NAME}/cmake/")

# For Windows
if( MSVC ) # VS2012 does not support tuples correctly yet
add_definitions( /D _VARIADIC_MAX=10 )
endif()

#====================== uninstall target ===============================
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.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)
23 changes: 23 additions & 0 deletions cmake_uninstall.cmake.in
@@ -0,0 +1,23 @@
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}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
exec_program(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
if(NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
endif(NOT "${rm_retval}" STREQUAL 0)
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
endforeach(file)


0 comments on commit 790f2b5

Please sign in to comment.