Skip to content

Commit bf0c27d

Browse files
committed
CAP-FIX: solved dlls cleaning/copying + basic tests structure
1 parent d1ab954 commit bf0c27d

File tree

6 files changed

+54
-72
lines changed

6 files changed

+54
-72
lines changed

CMakeLists.txt

Lines changed: 11 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
77
include(external_tools)
88
include(options)
99

10+
# check that the -DCMAKE_BUILD_TYPE is set
11+
if(NOT CMAKE_BUILD_TYPE)
12+
message(STATUS "Setting build type to 'Release' as none was specified.")
13+
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
14+
endif()
15+
1016
# do a submodule init if not done already
1117
execute_process(COMMAND git submodule update --init --recursive
1218
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
@@ -48,7 +54,7 @@ target_include_directories(${SHARED_LIB_NAME}
4854
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src
4955
)
5056

51-
#set the MD_DynamicRelease flag for MSVC since we are compiling with /MD for py wrap
57+
#set the MD_DynamicRelease flag for MSVC since we are compiling with /MD for py wrap
5258
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
5359

5460

@@ -146,31 +152,20 @@ if (BUILD_PYTHON_MODULE)
146152
$<TARGET_FILE:${PYBINDMODULE_NAME}>
147153
${PYPI_DIR}
148154
)
149-
150-
# get all the files -dlls in the bin directory and copy them one by one to the pypi directory
151-
file(GLOB files ${CMAKE_BINARY_DIR}/bin/Release/*.dll)
152-
foreach(file ${files})
153-
message(STATUS "Copying ${file} to ${TARGET_DLL_PYPI_DIR}")
154-
add_custom_command(TARGET ${PYBINDMODULE_NAME} POST_BUILD
155-
COMMAND ${CMAKE_COMMAND} -E copy
156-
${file}
157-
${TARGET_DLL_PYPI_DIR}
158-
)
159-
endforeach()
155+
copy_dlls(${TARGET_DLL_PYPI_DIR} ${PYBINDMODULE_NAME})
160156

161157
endif()
162158

163159
#--------------------------------------------------------------------------
164160
# Tests
165161
#--------------------------------------------------------------------------
166-
167162
include(CTest)
168163
enable_testing()
169164
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/googletest)
170165
set(TESTS_OUT_DIR ${CMAKE_BINARY_DIR}/df_tests/)
166+
set(TEST_OUT_DIR_BINARY ${TESTS_OUT_DIR}/${CMAKE_BUILD_TYPE})
171167

172-
173-
# Unit testing ------------------------------------------------------------
168+
# add new test suites .cc here
174169
set(UNIT_TESTS df_test_suites)
175170
add_executable(${UNIT_TESTS}
176171
tests/unit_tests/DFPointCloudTest.cc
@@ -179,40 +174,8 @@ add_executable(${UNIT_TESTS}
179174
set_target_properties(${UNIT_TESTS} PROPERTIES
180175
RUNTIME_OUTPUT_DIRECTORY ${TESTS_OUT_DIR}
181176
)
182-
183177
target_link_libraries(${UNIT_TESTS} gtest gtest_main)
184178
target_link_libraries(${UNIT_TESTS} ${SHARED_LIB_NAME})
185179

186180
add_test(NAME ${UNIT_TESTS} COMMAND ${UNIT_TESTS})
187-
188-
189-
190-
191-
192-
193-
194-
# # post build recipe
195-
# add_test(NAME ${UNIT_TEST} COMMAND ${UNIT_TEST})
196-
# add_custom_command(
197-
# TARGET ${UNIT_TEST}
198-
# COMMENT "Run tests"
199-
# POST_BUILD
200-
# WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
201-
# COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> -R "^${UNIT_TEST}$" --output-on-failures
202-
# )
203-
204-
# Integration testing -----------------------------------------------------
205-
# Component testing -------------------------------------------------------
206-
# etc ---------------------------------------------------------------------
207-
208-
# # TODO: a better way to copy the dlls to the tests directory for the tests
209-
# # get all the files -dlls in the bin directory and copy them one by one to tests dir
210-
# file(GLOB files ${CMAKE_BINARY_DIR}/bin/Release/*.dll)
211-
# foreach(file ${files})
212-
# message(STATUS "Copying ${file} to ${TESTS_OUT_DIR}")
213-
# add_custom_command(TARGET ${UNIT_TESTS} POST_BUILD
214-
# COMMAND ${CMAKE_COMMAND} -E copy
215-
# ${file}
216-
# ${TESTS_OUT_DIR}/Release
217-
# )
218-
# endforeach()
181+
copy_dlls(${TEST_OUT_DIR_BINARY} ${UNIT_TESTS})

cmake/__noenv__config.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
REM configure the project
2-
cmake -S . -B build
2+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

cmake/clean_config.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ REM clean the build directory and reconfigure it
55
rmdir /s /q build
66

77
REM configure the project
8-
cmake -S . -B build
8+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

cmake/config.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ REM activate the conda diff_check environment otherwise the python wrap won't wo
22
call cmake/activate_conda.bat
33

44
REM configure the project
5-
cmake -S . -B build
5+
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release

cmake/external_tools.cmake

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,23 @@ function(download_submodule_project project_name)
228228
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
229229
message(FATAL_ERROR "git submodule update --init --recursive --remote failed with ${GIT_SUBMOD_RESULT}, please checkout submodules")
230230
endif()
231+
endfunction()
232+
233+
# ------------------------------------------------------------------------------
234+
function (copy_dlls directory_to_copy_dlls post_build_target)
235+
message (STATUS "Erasing old DLLs and copy new ones to ${directory_to_copy_dlls}")
236+
file(GLOB files ${directory_to_copy_dlls}/*.dll)
237+
foreach(file ${files})
238+
message(STATUS "Removing ${file}")
239+
file(REMOVE ${file})
240+
endforeach()
241+
file(GLOB files ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE}/*.dll)
242+
foreach(file ${files})
243+
message(STATUS "Copying ${file} to ${directory_to_copy_dlls}")
244+
add_custom_command(TARGET ${post_build_target} POST_BUILD
245+
COMMAND ${CMAKE_COMMAND} -E copy
246+
${file}
247+
${directory_to_copy_dlls}
248+
)
249+
endforeach()
231250
endfunction()

src/diffCheckApp.cc

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,39 +12,39 @@ int main()
1212
std::shared_ptr<diffCheck::geometry::DFMesh> dfMeshPtr
1313
= std::make_shared<diffCheck::geometry::DFMesh>();
1414

15-
// create a sphere from o3d
16-
std::string pathCloud = R"(C:\andre\Downloads\moved_04.ply)";
17-
std::string pathMesh = R"(C:\Users\andre\Downloads\meshtest.ply)";
15+
// // create a sphere from o3d
16+
// std::string pathCloud = R"(C:\andre\Downloads\moved_04.ply)";
17+
// std::string pathMesh = R"(C:\Users\andre\Downloads\meshtest.ply)";
1818

19-
// dfPointCloudPtr->LoadFromPLY(pathCloud);
20-
dfMeshPtr->LoadFromPLY(pathMesh);
19+
// // dfPointCloudPtr->LoadFromPLY(pathCloud);
20+
// dfMeshPtr->LoadFromPLY(pathMesh);
2121

22-
open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh();
22+
// open3d::geometry::TriangleMesh meshO3d = *dfMeshPtr->Cvt2O3DTriangleMesh();
2323

2424

25-
// convert the sphere to a diffCheck point cloud
26-
// auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000);
25+
// // convert the sphere to a diffCheck point cloud
26+
// // auto o3dPointCloud = meshO3d.SamplePointsUniformly(1000);
2727

28-
std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>();
28+
// std::shared_ptr<open3d::geometry::PointCloud> tightBBOX = std::make_shared<open3d::geometry::PointCloud>();
2929

30-
// compute the bounding box
31-
open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox();
32-
std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints();
33-
for (auto &pt : bboxPts)
34-
{
35-
tightBBOX->points_.push_back(pt);
36-
}
30+
// // compute the bounding box
31+
// open3d::geometry::OrientedBoundingBox bbox = meshO3d.GetMinimalOrientedBoundingBox();
32+
// std::vector<Eigen::Vector3d> bboxPts = bbox.GetBoxPoints();
33+
// for (auto &pt : bboxPts)
34+
// {
35+
// tightBBOX->points_.push_back(pt);
36+
// }
3737

3838

39-
dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX);
39+
// dfPointCloudPtr->Cvt2DFPointCloud(tightBBOX);
4040

4141

4242

4343

44-
std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
45-
vis->AddPointCloud(dfPointCloudPtr);
46-
// vis->AddMesh(dfMeshPtr);
47-
vis->Run();
44+
// std::shared_ptr<diffCheck::visualizer::Visualizer> vis = std::make_shared<diffCheck::visualizer::Visualizer>();
45+
// vis->AddPointCloud(dfPointCloudPtr);
46+
// // vis->AddMesh(dfMeshPtr);
47+
// vis->Run();
4848

4949

5050
return 0;

0 commit comments

Comments
 (0)