forked from autowarefoundation/autoware.universe
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove COLCON_IGNORE * CMakeLists.txt & package.xml * Compiles * Remove rclcpp * Cleanup * Fix package.xml * Better CMakeLists.txt * Update CMakeLists.txt again * Update CMakeLists.txt * Update CMakeLists.txt yet again * Simplify CMakeLists.txt * Last (?) CMakeLists.txt change
- Loading branch information
1 parent
524502c
commit 9f105ec
Showing
4 changed files
with
100 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,111 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
cmake_minimum_required(VERSION 3.9) | ||
project(ndt_omp) | ||
|
||
# -mavx causes a lot of errors!! | ||
add_definitions(-std=c++14 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2) | ||
set(CMAKE_CXX_FLAGS "-std=c++14 -msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2") | ||
|
||
# warn performance issue of ndt_omp which is NOT built in release mode | ||
string(TOUPPER ${CMAKE_BUILD_TYPE} uppercase_CMAKE_BUILD_TYPE) | ||
if (NOT (${uppercase_CMAKE_BUILD_TYPE} STREQUAL "RELEASE")) | ||
message(WARNING | ||
"CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} may cause a serious performance degradation. Please configure with -DCMAKE_BUILD_TYPE=Release.") | ||
if(NOT CMAKE_CXX_STANDARD) | ||
set(CMAKE_CXX_STANDARD 14) | ||
endif() | ||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
add_compile_options(-Wall -Wextra -Wpedantic) | ||
add_compile_options(-Wno-unused-parameter) | ||
endif() | ||
|
||
find_package(catkin REQUIRED COMPONENTS | ||
roscpp | ||
pcl_ros | ||
) | ||
set(CMAKE_BUILD_TYPE "Release") | ||
|
||
find_package(ament_cmake REQUIRED) | ||
find_package(PCL REQUIRED COMPONENTS common filters kdtree registration io) | ||
find_package(OpenMP) | ||
if (OPENMP_FOUND) | ||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") | ||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") | ||
endif() | ||
|
||
catkin_package( | ||
INCLUDE_DIRS include | ||
LIBRARIES ndt_omp | ||
CATKIN_DEPENDS | ||
) | ||
|
||
########### | ||
## Build ## | ||
########### | ||
|
||
include_directories( | ||
include | ||
${catkin_INCLUDE_DIRS} | ||
) | ||
|
||
add_library(ndt_omp | ||
src/ndt_omp/voxel_grid_covariance_omp.cpp | ||
src/ndt_omp/ndt_omp.cpp | ||
) | ||
|
||
add_executable(align | ||
apps/align.cpp | ||
) | ||
add_dependencies(align | ||
ndt_omp | ||
target_include_directories(ndt_omp | ||
PUBLIC | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> | ||
$<INSTALL_INTERFACE:include> | ||
) | ||
# pcl 1.7 causes a segfault without -O2 (or -O3) flag | ||
target_compile_options(ndt_omp PUBLIC | ||
$<$<CONFIG:Debug>:-O2 -g> | ||
|
||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") | ||
target_compile_options(ndt_omp | ||
PRIVATE | ||
# -mavx causes a lot of errors!! | ||
-msse -msse2 -msse3 -msse4 -msse4.1 -msse4.2 | ||
) | ||
endif() | ||
|
||
set(NDT_OMP_DEPENDENCIES | ||
PCL | ||
OpenMP | ||
) | ||
target_link_libraries(align | ||
${catkin_LIBRARIES} | ||
ndt_omp | ||
|
||
|
||
# Naively, I'd want to do something like: | ||
# ament_target_dependencies(ndt_omp PUBLIC ${NDT_OMP_DEPENDENCIES}) | ||
# But there are several problems with that. For one, you'll have a hundred | ||
# errors like "undefined reference to `pcl::something::Something`". That's | ||
# because it only links `libpcl_common.so` for whatever reason, but we also | ||
# want `libpcl_io.so` etc. So we do this PCL thing manually: | ||
target_compile_definitions(ndt_omp PUBLIC ${PCL_DEFINITIONS}) | ||
target_include_directories(ndt_omp PUBLIC ${PCL_INCLUDE_DIRS}) | ||
target_link_libraries(ndt_omp PUBLIC ${PCL_LIBRARIES}) | ||
target_link_directories(ndt_omp PUBLIC ${PCL_LIBRARY_DIRS}) | ||
|
||
# As for OpenMP, the recommended format is the following, which is not | ||
# supported by `ament_target_dependencies()` either. | ||
if(OpenMP_CXX_FOUND) | ||
target_link_libraries(ndt_omp PUBLIC OpenMP::OpenMP_CXX) | ||
else() | ||
message(WARNING "OpenMP not found") | ||
endif() | ||
# See https://cliutils.gitlab.io/modern-cmake/chapters/packages/OpenMP.html | ||
# but it doesn't matter anyway because at the time of writing, omp.h is in | ||
# /usr/lib/gcc/x86_64-linux-gnu/9/include/ which is one of the default | ||
# include directories, and libgomp.so is in /usr/lib/x86_64-linux-gnu/, | ||
# which is one of the default linker search paths. | ||
|
||
ament_export_targets(export_ndt_omp HAS_LIBRARY_TARGET) | ||
ament_export_dependencies(${NDT_OMP_DEPENDENCIES}) | ||
|
||
|
||
# Same story for the executable | ||
add_executable(align | ||
apps/align.cpp | ||
) | ||
|
||
install(TARGETS ndt_omp | ||
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} | ||
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} | ||
target_compile_definitions(align PRIVATE ${PCL_DEFINITIONS}) | ||
target_include_directories(align PRIVATE ${PCL_INCLUDE_DIRS}) | ||
target_link_libraries(align PRIVATE ${PCL_LIBRARIES}) | ||
target_link_directories(align PRIVATE ${PCL_LIBRARY_DIRS}) | ||
if(OpenMP_CXX_FOUND) | ||
target_link_libraries(align PRIVATE OpenMP::OpenMP_CXX) | ||
else() | ||
message(WARNING "OpenMP not found") | ||
endif() | ||
|
||
# Again, no chance for `ament_target_dependencies()` since you can't depend on | ||
# a local library target: "ament_target_dependencies() the passed package name | ||
# 'ndt_omp' was not found" – so we need to add ndt_omp with | ||
# `target_link_libraries(align PUBLIC ndt_omp)` instead. | ||
target_link_libraries(align PRIVATE ndt_omp) | ||
|
||
install( | ||
DIRECTORY include/ | ||
DESTINATION include | ||
) | ||
|
||
## Install project namespaced headers | ||
install(DIRECTORY include/${PROJECT_NAME}/ | ||
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} | ||
install( | ||
TARGETS ndt_omp | ||
EXPORT export_ndt_omp | ||
LIBRARY DESTINATION lib | ||
ARCHIVE DESTINATION lib | ||
RUNTIME DESTINATION bin | ||
INCLUDES DESTINATION include | ||
) | ||
|
||
ament_package() | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters