@@ -7,6 +7,12 @@ list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
77include (external_tools)
88include (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
1117execute_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
5258set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL" )
5359
5460
@@ -78,7 +84,7 @@ target_link_libraries(${SHARED_LIB_NAME} PUBLIC Open3D::Open3D)
7884if (WIN32 )
7985 get_target_property (open3d_type Open3D::Open3D TYPE )
8086 if (open3d_type STREQUAL "SHARED_LIBRARY" )
81- message (STATUS "Copying Open3D.dll to ${CMAKE_CURRENT_BINARY_DIR} /$<CONFIG> " )
87+ message (STATUS "Copying Open3D.dll to ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_BUILD_TYPE} " )
8288 add_custom_command (TARGET ${SHARED_LIB_NAME} POST_BUILD
8389 COMMAND ${CMAKE_COMMAND} -E copy
8490 $<TARGET_FILE:Open3D::Open3D>
@@ -150,54 +156,30 @@ if (BUILD_PYTHON_MODULE)
150156 $<TARGET_FILE:${PYBINDMODULE_NAME} >
151157 ${PYPI_DIR}
152158 )
153-
154- # get all the files -dlls in the bin directory and copy them one by one to the pypi directory
155- file (GLOB files ${CMAKE_BINARY_DIR} /bin/Release/*.dll)
156- foreach (file ${files} )
157- message (STATUS "Copying ${file} to ${TARGET_DLL_PYPI_DIR} " )
158- add_custom_command (TARGET ${PYBINDMODULE_NAME} POST_BUILD
159- COMMAND ${CMAKE_COMMAND} -E copy
160- ${file}
161- ${TARGET_DLL_PYPI_DIR}
162- )
163- endforeach ()
159+ copy_dlls(${TARGET_DLL_PYPI_DIR} ${PYBINDMODULE_NAME} )
164160
165161endif ()
166162
167163#--------------------------------------------------------------------------
168164# Tests
169165#--------------------------------------------------------------------------
166+ include (CTest)
167+ enable_testing ()
168+ add_subdirectory (${CMAKE_CURRENT_SOURCE_DIR} /deps/googletest)
169+ set (TESTS_OUT_DIR ${CMAKE_BINARY_DIR} /df_tests/)
170+ set (TEST_OUT_DIR_BINARY ${TESTS_OUT_DIR} /${CMAKE_BUILD_TYPE} )
171+
172+ # add new test suites .cc here
173+ set (UNIT_TESTS df_test_suites)
174+ add_executable (${UNIT_TESTS}
175+ tests/unit_tests/DFPointCloudTest.cc
176+ tests/entryTest.cc
177+ )
178+ set_target_properties (${UNIT_TESTS} PROPERTIES
179+ RUNTIME_OUTPUT_DIRECTORY ${TESTS_OUT_DIR}
180+ )
181+ target_link_libraries (${UNIT_TESTS} gtest gtest_main)
182+ target_link_libraries (${UNIT_TESTS} ${SHARED_LIB_NAME} )
170183
171- # include(CTest)
172- # enable_testing()
173- # add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/deps/googletest)
174- # set(TESTS_OUT_DIR ${CMAKE_BINARY_DIR}/tests/)
175-
176-
177- # # Unit testing ------------------------------------------------------------
178- # set(UNIT_TESTS unit_tests)
179- # add_executable(${UNIT_TESTS} tests/unit_tests/DFPointCloudTest.cc)
180- # set_target_properties(${UNIT_TESTS} PROPERTIES
181- # RUNTIME_OUTPUT_DIRECTORY ${TESTS_OUT_DIR}
182- # )
183-
184- # target_link_libraries(${UNIT_TESTS} gtest gtest_main)
185- # target_link_libraries(${UNIT_TESTS} ${SHARED_LIB_NAME})
186-
187- # add_test(NAME ${UNIT_TESTS} COMMAND ${UNIT_TESTS})
188-
189- # Integration testing -----------------------------------------------------
190- # Component testing -------------------------------------------------------
191- # etc ---------------------------------------------------------------------
192-
193- # # TODO: a better way to copy the dlls to the tests directory for the tests
194- # # get all the files -dlls in the bin directory and copy them one by one to tests dir
195- # file(GLOB files ${CMAKE_BINARY_DIR}/bin/Release/*.dll)
196- # foreach(file ${files})
197- # message(STATUS "Copying ${file} to ${TESTS_OUT_DIR}")
198- # add_custom_command(TARGET ${UNIT_TESTS} POST_BUILD
199- # COMMAND ${CMAKE_COMMAND} -E copy
200- # ${file}
201- # ${TESTS_OUT_DIR}/Release
202- # )
203- # endforeach()
184+ add_test (NAME ${UNIT_TESTS} COMMAND ${UNIT_TESTS} )
185+ copy_dlls(${TEST_OUT_DIR_BINARY} ${UNIT_TESTS} )
0 commit comments