Skip to content

Commit 1d8cce8

Browse files
authored
Fix VS2022 build (OpenMP optional) and debugger working directory for examples/tests (#119)
* Pass compile on Windows * Set debugger working diretoriy as project root for examples and tests on Windows
1 parent 08bc50b commit 1d8cce8

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

CMakeLists.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,10 @@ endif()
9797

9898
if(MSVC)
9999
add_compile_definitions(_USE_MATH_DEFINES)
100-
# add_compile_options(/openmp:llvm)
100+
add_compile_options(/bigobj)
101+
if(BUILD_WITH_OPENMP)
102+
add_compile_options(/openmp:llvm)
103+
endif()
101104
endif()
102105

103106
##############
@@ -247,6 +250,12 @@ if(BUILD_EXAMPLES)
247250
TBB::tbbmalloc
248251
PCL::PCL
249252
)
253+
if(MSVC)
254+
set_target_properties(${EXAMPLE_NAME}
255+
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY
256+
"${CMAKE_SOURCE_DIR}"
257+
)
258+
endif()
250259
endforeach()
251260
endif()
252261

@@ -273,6 +282,13 @@ if(BUILD_TESTS)
273282
)
274283

275284
gtest_discover_tests(${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
285+
286+
if(MSVC)
287+
set_target_properties(${TEST_NAME}
288+
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY
289+
"${CMAKE_SOURCE_DIR}"
290+
)
291+
endif()
276292
endforeach()
277293
endif()
278294

include/small_gicp/pcl/pcl_registration.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ class RegistrationPCL : public pcl::Registration<PointSource, PointTarget, float
9999
std::string registration_type_; ///< Registration type ("GICP" or "VGICP").
100100
bool verbose_; ///< Verbosity flag.
101101

102-
std::shared_ptr<KdTree<pcl::PointCloud<PointSource>>> target_tree_; ///< KdTree for target point cloud.
103-
std::shared_ptr<KdTree<pcl::PointCloud<PointSource>>> source_tree_; ///< KdTree for source point cloud.
102+
std::shared_ptr<small_gicp::KdTree<pcl::PointCloud<PointSource>>> target_tree_; ///< KdTree for target point cloud.
103+
std::shared_ptr<small_gicp::KdTree<pcl::PointCloud<PointSource>>> source_tree_; ///< KdTree for source point cloud.
104104

105105
std::shared_ptr<GaussianVoxelMap> target_voxelmap_; ///< VoxelMap for target point cloud.
106106
std::shared_ptr<GaussianVoxelMap> source_voxelmap_; ///< VoxelMap for source point cloud.

include/small_gicp/pcl/pcl_registration_impl.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void RegistrationPCL<PointSource, PointTarget>::setInputSource(const PointCloudS
4444
}
4545

4646
pcl::Registration<PointSource, PointTarget, Scalar>::setInputSource(cloud);
47-
source_tree_ = std::make_shared<KdTree<pcl::PointCloud<PointSource>>>(input_, KdTreeBuilderOMP(num_threads_));
47+
source_tree_ = std::make_shared<small_gicp::KdTree<pcl::PointCloud<PointSource>>>(input_, KdTreeBuilderOMP(num_threads_));
4848
source_covs_.clear();
4949
source_voxelmap_.reset();
5050
}
@@ -56,7 +56,7 @@ void RegistrationPCL<PointSource, PointTarget>::setInputTarget(const PointCloudT
5656
}
5757

5858
pcl::Registration<PointSource, PointTarget, Scalar>::setInputTarget(cloud);
59-
target_tree_ = std::make_shared<KdTree<pcl::PointCloud<PointTarget>>>(target_, KdTreeBuilderOMP(num_threads_));
59+
target_tree_ = std::make_shared<small_gicp::KdTree<pcl::PointCloud<PointTarget>>>(target_, KdTreeBuilderOMP(num_threads_));
6060
target_covs_.clear();
6161
target_voxelmap_.reset();
6262
}
@@ -214,7 +214,7 @@ void RegistrationPCL<PointSource, PointTarget>::computeTransformation(PointCloud
214214
estimate_covariances_omp(target_proxy, *target_tree_, k_correspondences_, num_threads_);
215215
}
216216

217-
Registration<GICPFactor, ParallelReductionOMP> registration;
217+
small_gicp::Registration<GICPFactor, ParallelReductionOMP> registration;
218218
registration.criteria.rotation_eps = rotation_epsilon_;
219219
registration.criteria.translation_eps = transformation_epsilon_;
220220
registration.reduction.num_threads = num_threads_;

include/small_gicp/registration/reduction_omp.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
namespace small_gicp {
88

99
#ifndef _OPENMP
10+
#ifdef _WIN32
11+
#pragma message(__FILE__, " OpenMP is not available.Parallel reduction will be disabled.")
12+
#else
1013
#warning "OpenMP is not available. Parallel reduction will be disabled."
14+
#endif
1115
inline int omp_get_thread_num() {
1216
return 0;
1317
}

0 commit comments

Comments
 (0)