From f8fdd06a089777809fc8abe1956932ff7d982732 Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Mon, 26 Oct 2020 15:17:06 +0100 Subject: [PATCH 1/9] [libpointmatcher] Added cmake files to support pure make or catkin builds --- CMakeLists.txt | 12 ++++++------ UseDoxygen.cmake => cmake/UseDoxygen.cmake | 0 .../cmake_uninstall.cmake.in | 0 .../libnaboConfig.cmake.in | 0 .../libnaboConfigVersion.cmake.in | 0 package.xml | 5 ++++- 6 files changed, 10 insertions(+), 7 deletions(-) rename UseDoxygen.cmake => cmake/UseDoxygen.cmake (100%) rename cmake_uninstall.cmake.in => cmake/cmake_uninstall.cmake.in (100%) rename libnaboConfig.cmake.in => cmake/libnaboConfig.cmake.in (100%) rename libnaboConfigVersion.cmake.in => cmake/libnaboConfigVersion.cmake.in (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 920358e..abc5636 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ endif() option(LIBNABO_BUILD_DOXYGEN "Build libnabo doxygen documentation" ON) if (LIBNABO_BUILD_DOXYGEN) set(DOXYFILE_LATEX false) - include(UseDoxygen) + include(cmake/UseDoxygen) endif() # Switch on warnings. @@ -253,7 +253,7 @@ set(libnabo_library $) # Create variable for the local build tree get_property(libnabo_include_dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) # Configure & generate config file for local build tree -configure_file(libnaboConfig.cmake.in +configure_file(cmake/libnaboConfig.cmake.in "${PROJECT_BINARY_DIR}/libnaboConfig.cmake.conf" @ONLY) file(GENERATE OUTPUT "${PROJECT_BINARY_DIR}/libnaboConfig.cmake" @@ -268,14 +268,14 @@ set(libnabo_library ${CMAKE_INSTALL_PREFIX}/lib/$) set(libnabo_include_dirs ${CMAKE_INSTALL_PREFIX}/include) # We put the generated file for installation in a different repository (i.e., ./CMakeFiles/) -configure_file(libnaboConfig.cmake.in +configure_file(cmake/libnaboConfig.cmake.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libnaboConfig.cmake.conf" @ONLY) file(GENERATE OUTPUT "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libnaboConfig.cmake" INPUT "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/libnaboConfig.cmake.conf") # The same versioning file can be used for both cases -configure_file(libnaboConfigVersion.cmake.in +configure_file(cmake/libnaboConfigVersion.cmake.in "${PROJECT_BINARY_DIR}/libnaboConfigVersion.cmake" @ONLY) install(FILES @@ -289,8 +289,8 @@ install(FILES #============================================= if (NOT TARGET uninstall) configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" - "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/cmake/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall diff --git a/UseDoxygen.cmake b/cmake/UseDoxygen.cmake similarity index 100% rename from UseDoxygen.cmake rename to cmake/UseDoxygen.cmake diff --git a/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in similarity index 100% rename from cmake_uninstall.cmake.in rename to cmake/cmake_uninstall.cmake.in diff --git a/libnaboConfig.cmake.in b/cmake/libnaboConfig.cmake.in similarity index 100% rename from libnaboConfig.cmake.in rename to cmake/libnaboConfig.cmake.in diff --git a/libnaboConfigVersion.cmake.in b/cmake/libnaboConfigVersion.cmake.in similarity index 100% rename from libnaboConfigVersion.cmake.in rename to cmake/libnaboConfigVersion.cmake.in diff --git a/package.xml b/package.xml index 202939d..b677769 100644 --- a/package.xml +++ b/package.xml @@ -19,8 +19,11 @@ boost catkin + + + cmake + --> From 3cc071290384d3d6c0ade436214794e0f65f605c Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Mon, 26 Oct 2020 15:18:36 +0100 Subject: [PATCH 2/9] [package.xml] Changed default buildtool --- package.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.xml b/package.xml index b677769..19c1574 100644 --- a/package.xml +++ b/package.xml @@ -11,8 +11,9 @@ https://github.com/ethz-asl/libnabo Stéphane Magnenat - + cmake + eigen boost eigen From 89d1da70d8bac10a22e856cb14e6bbede9a5cd79 Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Mon, 26 Oct 2020 15:19:32 +0100 Subject: [PATCH 3/9] [CMakeLists.txt] File rename and move --- CMakeLists.txt => cmake/PureCMakeBuild.cmake | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CMakeLists.txt => cmake/PureCMakeBuild.cmake (100%) diff --git a/CMakeLists.txt b/cmake/PureCMakeBuild.cmake similarity index 100% rename from CMakeLists.txt rename to cmake/PureCMakeBuild.cmake From c9414bb2335cf3b07ce3cb65c09f6cb6c3f73d1d Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Mon, 26 Oct 2020 15:25:34 +0100 Subject: [PATCH 4/9] [cmake] Added catkin cmake file --- CMakeLists.txt | 28 +++++++++++++++ cmake/CatkinBuild.cmake | 72 ++++++++++++++++++++++++++++++++++++++ cmake/PureCMakeBuild.cmake | 8 ----- package.xml | 4 ++- 4 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake/CatkinBuild.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..3deb9cd --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.5.1) +project(libnabo) + +# Source and header files. +set(NABO_SRC + nabo/nabo.cpp + nabo/brute_force_cpu.cpp + nabo/kdtree_cpu.cpp + nabo/kdtree_opencl.cpp +) + +file(GLOB_RECURSE NABO_HEADERS "nabo/*.h") + +# Global compiler flags. +add_compile_options(-Wall -Wextra -Wpedantic) + +# Build type options: +# * catkin. +# * cmake. +# * ament (future). +set(BUILD_TYPE "catkin") +if (BUILD_TYPE STREQUAL "catkin") + include(cmake/CatkinBuild.cmake) +else() + # For a pure-cmake build, follow the instructions on the package.xml file, which + # specify how to set the buildtool to cmake and export the package accordingly. + include(cmake/PureCMakeBuild.cmake) +endif() diff --git a/cmake/CatkinBuild.cmake b/cmake/CatkinBuild.cmake new file mode 100644 index 0000000..b885771 --- /dev/null +++ b/cmake/CatkinBuild.cmake @@ -0,0 +1,72 @@ +# Set compiler flags +set(CMAKE_CXX_STANDARD 14) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + add_definitions(-O3) +endif(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + +# Find catkin macros and libraries +find_package(catkin REQUIRED) +find_package(Eigen3 REQUIRED) +find_package(Boost REQUIRED COMPONENTS python) + +find_package(OpenMP REQUIRED) +if (OpenMP_FOUND) + add_compile_options("${OpenMP_CXX_FLAGS}") + add_definitions(-DHAVE_OPENMP=${OpenMP_FOUND}) +endif() + +# Catkin package macro +catkin_package( + INCLUDE_DIRS + nabo + ${CMAKE_SOURCE_DIR} + ${EIGEN3_INCLUDE_DIR} + LIBRARIES + nabo + DEPENDS + Boost +) + +######################## +## Library definition ## +######################## +# Nabo +add_library(nabo + ${NABO_SRC} + ${NABO_HEADERS} +) + +target_include_directories(nabo + PUBLIC + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/nabo + SYSTEM + ${EIGEN3_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + ${OpenMP_CXX_INCLUDE_DIRS} +) + +target_link_libraries(nabo + ${catkin_LIBRARIES} + ${Boost_LIBRARIES} + ${OpenMP_CXX_LIBRARIES} +) + +############# +## Install ## +############# +install( + TARGETS + nabo + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} +) + +install( + DIRECTORY + ${CMAKE_SOURCE_DIR}/nabo/ + DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/nabo +) \ No newline at end of file diff --git a/cmake/PureCMakeBuild.cmake b/cmake/PureCMakeBuild.cmake index abc5636..89b8a0b 100644 --- a/cmake/PureCMakeBuild.cmake +++ b/cmake/PureCMakeBuild.cmake @@ -132,14 +132,6 @@ else () message("OpenCL disabled, not looking for it") endif () - -# main nabo lib -set(NABO_SRC - nabo/nabo.cpp - nabo/brute_force_cpu.cpp - nabo/kdtree_cpu.cpp - nabo/kdtree_opencl.cpp -) set(SHARED_LIBS FALSE CACHE BOOL "Set to TRUE to build shared library") if (SHARED_LIBS) add_library(${LIB_NAME} SHARED ${NABO_SRC}) diff --git a/package.xml b/package.xml index 19c1574..cc084b7 100644 --- a/package.xml +++ b/package.xml @@ -12,10 +12,12 @@ Stéphane Magnenat - cmake + catkin eigen boost + libopenmp-dev + eigen boost catkin From 0b574253bf820c4a995e405922ef881c64bb0cf6 Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Mon, 26 Oct 2020 15:31:16 +0100 Subject: [PATCH 5/9] [package.xml] Fixed depends --- package.xml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/package.xml b/package.xml index cc084b7..2190502 100644 --- a/package.xml +++ b/package.xml @@ -14,13 +14,12 @@ catkin - eigen boost + eigen libopenmp-dev - eigen boost - catkin + eigen From 641f17716c028803422a20e41c73490c6261e3c3 Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Mon, 26 Oct 2020 15:32:34 +0100 Subject: [PATCH 6/9] [cmake] Default build tool set to catkin --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3deb9cd..a0c4b48 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ add_compile_options(-Wall -Wextra -Wpedantic) # * catkin. # * cmake. # * ament (future). -set(BUILD_TYPE "catkin") +set(BUILD_TYPE "cmake") if (BUILD_TYPE STREQUAL "catkin") include(cmake/CatkinBuild.cmake) else() From 3177e0f00b2aabeaa3f52b05f23e6212c4df4a36 Mon Sep 17 00:00:00 2001 From: YoshuaNava Date: Thu, 29 Oct 2020 16:37:55 +0100 Subject: [PATCH 7/9] Reduce target cmake version to 2.8.12 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a0c4b48..b3c142e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.5.1) +cmake_minimum_required(VERSION 2.8.12) project(libnabo) # Source and header files. From 4bbfee963f90df45a9b78ac24573032247930cb8 Mon Sep 17 00:00:00 2001 From: Yoshua Nava Date: Fri, 20 Nov 2020 07:28:32 +0100 Subject: [PATCH 8/9] Address comments from pull request --- cmake/CatkinBuild.cmake | 42 +++++++++++++++++++++++------------------ package.xml | 5 +---- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/cmake/CatkinBuild.cmake b/cmake/CatkinBuild.cmake index b885771..6ae02e2 100644 --- a/cmake/CatkinBuild.cmake +++ b/cmake/CatkinBuild.cmake @@ -11,22 +11,18 @@ find_package(catkin REQUIRED) find_package(Eigen3 REQUIRED) find_package(Boost REQUIRED COMPONENTS python) -find_package(OpenMP REQUIRED) -if (OpenMP_FOUND) - add_compile_options("${OpenMP_CXX_FLAGS}") - add_definitions(-DHAVE_OPENMP=${OpenMP_FOUND}) +find_package(OpenMP) +if (NOT OpenMP_FOUND) + message("OpenMP was not found. It is highly recommended to build libnabo with OpenMP support.") endif() # Catkin package macro catkin_package( INCLUDE_DIRS - nabo ${CMAKE_SOURCE_DIR} ${EIGEN3_INCLUDE_DIR} LIBRARIES nabo - DEPENDS - Boost ) ######################## @@ -37,22 +33,29 @@ add_library(nabo ${NABO_SRC} ${NABO_HEADERS} ) - -target_include_directories(nabo - PUBLIC - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/nabo - SYSTEM - ${EIGEN3_INCLUDE_DIR} - ${Boost_INCLUDE_DIRS} - ${OpenMP_CXX_INCLUDE_DIRS} +target_include_directories(nabo PUBLIC + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/nabo ) - -target_link_libraries(nabo +target_include_directories(nabo SYSTEM PRIVATE + ${EIGEN3_INCLUDE_DIR} + ${Boost_INCLUDE_DIRS} + ${OpenMP_CXX_INCLUDE_DIRS} +) +target_link_libraries(nabo PRIVATE ${catkin_LIBRARIES} ${Boost_LIBRARIES} ${OpenMP_CXX_LIBRARIES} ) +target_compile_options(nabo PRIVATE + "${OpenMP_CXX_FLAGS}" +) +target_compile_definitions(nabo PRIVATE + -DHAVE_OPENMP=${OpenMP_FOUND} +) + +# Python bindings +add_subdirectory(python) ############# ## Install ## @@ -69,4 +72,7 @@ install( DIRECTORY ${CMAKE_SOURCE_DIR}/nabo/ DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}/nabo + FILES_MATCHING + PATTERN "*.h" + PATTERN "*.hpp" ) \ No newline at end of file diff --git a/package.xml b/package.xml index 2190502..6c41898 100644 --- a/package.xml +++ b/package.xml @@ -16,10 +16,7 @@ boost eigen - libopenmp-dev - - boost - eigen + libomp-dev From be08549706c0945c0fa32d8603524f5f325b2cdd Mon Sep 17 00:00:00 2001 From: Yoshua Nava Date: Fri, 20 Nov 2020 07:36:28 +0100 Subject: [PATCH 9/9] Package.xml update --- package.xml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.xml b/package.xml index 6c41898..36c4b7d 100644 --- a/package.xml +++ b/package.xml @@ -1,5 +1,4 @@ - - + libnabo 1.0.7