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
This commit is contained in:
unclearness 2025-06-10 12:48:47 +09:00 committed by GitHub
parent 08bc50beff
commit 1d8cce8add
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 26 additions and 6 deletions

View File

@ -97,7 +97,10 @@ endif()
if(MSVC)
add_compile_definitions(_USE_MATH_DEFINES)
# add_compile_options(/openmp:llvm)
add_compile_options(/bigobj)
if(BUILD_WITH_OPENMP)
add_compile_options(/openmp:llvm)
endif()
endif()
##############
@ -247,6 +250,12 @@ if(BUILD_EXAMPLES)
TBB::tbbmalloc
PCL::PCL
)
if(MSVC)
set_target_properties(${EXAMPLE_NAME}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
)
endif()
endforeach()
endif()
@ -273,6 +282,13 @@ if(BUILD_TESTS)
)
gtest_discover_tests(${TEST_NAME} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
if(MSVC)
set_target_properties(${TEST_NAME}
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY
"${CMAKE_SOURCE_DIR}"
)
endif()
endforeach()
endif()

View File

@ -99,8 +99,8 @@ protected:
std::string registration_type_; ///< Registration type ("GICP" or "VGICP").
bool verbose_; ///< Verbosity flag.
std::shared_ptr<KdTree<pcl::PointCloud<PointSource>>> target_tree_; ///< KdTree for target point cloud.
std::shared_ptr<KdTree<pcl::PointCloud<PointSource>>> source_tree_; ///< KdTree for source point cloud.
std::shared_ptr<small_gicp::KdTree<pcl::PointCloud<PointSource>>> target_tree_; ///< KdTree for target point cloud.
std::shared_ptr<small_gicp::KdTree<pcl::PointCloud<PointSource>>> source_tree_; ///< KdTree for source point cloud.
std::shared_ptr<GaussianVoxelMap> target_voxelmap_; ///< VoxelMap for target point cloud.
std::shared_ptr<GaussianVoxelMap> source_voxelmap_; ///< VoxelMap for source point cloud.

View File

@ -44,7 +44,7 @@ void RegistrationPCL<PointSource, PointTarget>::setInputSource(const PointCloudS
}
pcl::Registration<PointSource, PointTarget, Scalar>::setInputSource(cloud);
source_tree_ = std::make_shared<KdTree<pcl::PointCloud<PointSource>>>(input_, KdTreeBuilderOMP(num_threads_));
source_tree_ = std::make_shared<small_gicp::KdTree<pcl::PointCloud<PointSource>>>(input_, KdTreeBuilderOMP(num_threads_));
source_covs_.clear();
source_voxelmap_.reset();
}
@ -56,7 +56,7 @@ void RegistrationPCL<PointSource, PointTarget>::setInputTarget(const PointCloudT
}
pcl::Registration<PointSource, PointTarget, Scalar>::setInputTarget(cloud);
target_tree_ = std::make_shared<KdTree<pcl::PointCloud<PointTarget>>>(target_, KdTreeBuilderOMP(num_threads_));
target_tree_ = std::make_shared<small_gicp::KdTree<pcl::PointCloud<PointTarget>>>(target_, KdTreeBuilderOMP(num_threads_));
target_covs_.clear();
target_voxelmap_.reset();
}
@ -214,7 +214,7 @@ void RegistrationPCL<PointSource, PointTarget>::computeTransformation(PointCloud
estimate_covariances_omp(target_proxy, *target_tree_, k_correspondences_, num_threads_);
}
Registration<GICPFactor, ParallelReductionOMP> registration;
small_gicp::Registration<GICPFactor, ParallelReductionOMP> registration;
registration.criteria.rotation_eps = rotation_epsilon_;
registration.criteria.translation_eps = transformation_epsilon_;
registration.reduction.num_threads = num_threads_;

View File

@ -7,7 +7,11 @@
namespace small_gicp {
#ifndef _OPENMP
#ifdef _WIN32
#pragma message(__FILE__, " OpenMP is not available.Parallel reduction will be disabled.")
#else
#warning "OpenMP is not available. Parallel reduction will be disabled."
#endif
inline int omp_get_thread_num() {
return 0;
}