2020-12-07 13:18:53 +01:00
include ( VCICommon )
2011-09-01 09:28:38 +00:00
2022-02-23 10:14:10 +01:00
set ( UNITTEST_SRC
u n i t t e s t s . c c
u n i t t e s t s _ a d d _ f a c e . c c
u n i t t e s t s _ b o u n d a r y . c c
u n i t t e s t s _ c e n t r o i d _ c a l c u l a t i o n s . c c
u n i t t e s t s _ c o n v e r t _ m e s h e s . c c
u n i t t e s t s _ c p p _ 1 1 _ f e a t u r e s . c c
u n i t t e s t s _ d e c i m a t e r . c c
u n i t t e s t s _ d e l e t e _ f a c e . c c
u n i t t e s t s _ e i g e n 3 _ t y p e . c c
u n i t t e s t s _ f a c e l e s s _ m e s h . c c
u n i t t e s t s _ m c _ d e c i m a t e r . c c
u n i t t e s t s _ m e s h _ c a s t . c c
u n i t t e s t s _ m e s h _ d u a l . c c
u n i t t e s t s _ m e s h _ t y p e . c c
u n i t t e s t s _ m i x e d _ d e c i m a t e r . c c
u n i t t e s t s _ n o r m a l _ c a l c u l a t i o n s . c c
u n i t t e s t s _ p o l y m e s h _ c o l l a p s e . c c
u n i t t e s t s _ p o l y m e s h _ v e c 2 i . c c
u n i t t e s t s _ p r o p e r t y . c c
u n i t t e s t s _ p r o p e r t y m a n a g e r . c c
u n i t t e s t s _ r a n d o m N u m b e r G e n e r a t o r . c c
u n i t t e s t s _ r e a d _ w r i t e _ O B J . c c
u n i t t e s t s _ r e a d _ w r i t e _ O F F . c c
u n i t t e s t s _ r e a d _ w r i t e _ O M . c c
u n i t t e s t s _ r e a d _ w r i t e _ P L Y . c c
u n i t t e s t s _ r e a d _ w r i t e _ S T L . c c
u n i t t e s t s _ s e t _ p o s i t i o n s _ d i r e c t l y . c c
u n i t t e s t s _ s m a r t _ h a n d l e s . c c
u n i t t e s t s _ s m a r t _ r a n g e s . c c
u n i t t e s t s _ s m a r t t a g g e r . c c
u n i t t e s t s _ s m o o t h e r . c c
u n i t t e s t s _ s p l i t _ c o p y . c c
u n i t t e s t s _ s p l i t _ e d g e _ c o p y . c c
u n i t t e s t s _ s r _ b i n a r y . c c
u n i t t e s t s _ s t r i p i f i e r . c c
u n i t t e s t s _ s u b d i v i d e r _ a d a p t i v e . c c
u n i t t e s t s _ s u b d i v i d e r _ u n i f o r m . c c
2023-08-24 12:42:41 +02:00
u n i t t e s t s _ t r a i t s . c c
2023-11-14 07:57:17 +00:00
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ c u r r e n t _ h a l f e d g e _ h a n d l e _ r e p l a c e m e n t . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ e d g e _ f a c e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ e d g e _ h a l f e d g e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ e d g e _ v e r t e x . c c
2022-02-23 10:14:10 +01:00
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ f a c e _ e d g e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ f a c e _ f a c e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ f a c e _ h a l f e d g e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ f a c e _ v e r t e x . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ h a l f e d g e _ l o o p . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ v e r t e x _ e d g e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ v e r t e x _ f a c e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ v e r t e x _ i h a l f e d g e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ v e r t e x _ o h a l f e d g e . c c
u n i t t e s t s _ t r i m e s h _ c i r c u l a t o r _ v e r t e x _ v e r t e x . c c
u n i t t e s t s _ t r i m e s h _ c o l l a p s e . c c
u n i t t e s t s _ t r i m e s h _ g a r b a g e _ c o l l e c t i o n . c c
u n i t t e s t s _ t r i m e s h _ i t e r a t o r s . c c
2023-11-14 07:57:17 +00:00
u n i t t e s t s _ t r i m e s h _ n a v i g a t i o n . c c
2022-02-23 10:14:10 +01:00
u n i t t e s t s _ t r i m e s h _ o t h e r s . c c
u n i t t e s t s _ t r i m e s h _ r a n g e s . c c
u n i t t e s t s _ t r i m e s h _ s p l i t . c c
u n i t t e s t s _ t r i m e s h _ v e c 2 i . c c
u n i t t e s t s _ t u t o r i a l s . c c
u n i t t e s t s _ v d p m . c c
u n i t t e s t s _ v e c t o r _ t y p e . c c
)
2012-02-29 10:30:21 +00:00
if ( NOT DEFINED OPENMESH_BUILD_UNIT_TESTS )
set ( OPENMESH_BUILD_UNIT_TESTS false CACHE BOOL "Enable or disable unit test builds in OpenMesh." )
endif ( )
2011-09-01 09:28:38 +00:00
2012-02-29 10:30:21 +00:00
if ( OPENMESH_BUILD_UNIT_TESTS )
# Search for gtest headers and libraries
2018-06-09 12:13:15 +02:00
find_package ( GTest )
2012-02-29 10:30:21 +00:00
if ( GTEST_FOUND )
2012-02-23 14:00:41 +00:00
enable_testing ( )
2011-09-01 09:28:38 +00:00
2020-12-02 19:26:21 +01:00
find_package ( Eigen3 )
2019-01-17 07:40:34 +01:00
2011-09-01 09:28:38 +00:00
# Set correct include paths so that the compiler can find the headers
2019-01-17 08:27:40 +01:00
include_directories ( ${ GTEST_INCLUDE_DIRS } )
2011-09-29 14:11:04 +00:00
# set additional link directories
link_directories ( ${ GTEST_LIBRARY_DIR } )
2013-08-09 11:26:12 +00:00
2019-01-17 07:40:34 +01:00
2020-12-02 19:26:21 +01:00
if ( TARGET Eigen3::Eigen )
2019-01-17 08:27:40 +01:00
add_definitions ( -DENABLE_EIGEN3_TEST )
2020-12-02 19:26:21 +01:00
link_libraries ( Eigen3::Eigen )
2021-01-15 13:58:48 +01:00
else ( )
message ( WARNING "Eigen3 not found! This will skip the Eigen3 Unittests. You can point cmake to Eigen3 by setting Eigen3_DIR to the cmake files of Eigen3" )
2019-01-17 07:40:34 +01:00
endif ( )
2011-09-01 09:28:38 +00:00
# Create new target named unittests_hexmeshing
2019-01-17 07:40:34 +01:00
# Create unittest executable
2020-12-07 13:18:53 +01:00
vci_add_executable ( unittests ${ UNITTEST_SRC } )
vci_add_executable ( unittests_customvec ${ UNITTEST_SRC } )
vci_add_executable ( unittests_doublevec ${ UNITTEST_SRC } )
2019-01-17 07:40:34 +01:00
target_compile_definitions ( unittests_customvec PRIVATE TEST_CUSTOM_TRAITS )
2019-10-22 10:17:12 +02:00
target_compile_definitions ( unittests_doublevec PRIVATE TEST_DOUBLE_TRAITS )
2015-06-16 10:57:51 +00:00
2020-12-07 13:18:53 +01:00
# For the unittest we don't want the install rpath as set by vci_add_executable
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
2019-01-17 07:40:34 +01:00
set_target_properties ( unittests_customvec PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests_doublevec PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
2015-06-16 10:57:51 +00:00
2015-06-18 11:23:28 +00:00
# Set output directory to ${BINARY_DIR}/Unittests
set ( OUTPUT_DIR "${CMAKE_BINARY_DIR}/Unittests" )
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ OUTPUT_DIR } )
2018-04-12 15:19:53 +02:00
set_target_properties ( unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ OUTPUT_DIR } )
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests_doublevec PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ OUTPUT_DIR } )
2015-06-18 11:23:28 +00:00
foreach ( CONFIG ${ CMAKE_CONFIGURATION_TYPES } )
string ( TOUPPER ${ CONFIG } UPCONFIG )
set_target_properties ( unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY_ ${ UPCONFIG } ${ OUTPUT_DIR } )
2018-04-18 12:24:21 +02:00
set_target_properties ( unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_ ${ UPCONFIG } ${ OUTPUT_DIR } )
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests_doublevec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_ ${ UPCONFIG } ${ OUTPUT_DIR } )
2015-06-18 11:23:28 +00:00
endforeach ( )
2011-10-10 14:34:24 +00:00
2012-09-24 10:10:22 +00:00
if ( NOT WIN32 )
2015-06-16 10:57:51 +00:00
# Link against all necessary libraries
target_link_libraries ( unittests OpenMeshCore OpenMeshTools ${ GTEST_LIBRARIES } ${ GTEST_MAIN_LIBRARIES } pthread )
2018-04-12 15:19:53 +02:00
target_link_libraries ( unittests_customvec OpenMeshCore OpenMeshTools ${ GTEST_LIBRARIES } ${ GTEST_MAIN_LIBRARIES } pthread )
2019-10-22 10:17:12 +02:00
target_link_libraries ( unittests_doublevec OpenMeshCore OpenMeshTools ${ GTEST_LIBRARIES } ${ GTEST_MAIN_LIBRARIES } pthread )
2011-10-10 14:34:24 +00:00
2015-06-18 11:23:28 +00:00
2011-10-10 14:34:24 +00:00
2015-06-16 10:57:51 +00:00
else ( )
2012-02-29 10:30:21 +00:00
# Link against all necessary libraries
2012-09-24 10:10:22 +00:00
if ( OPENMESH_BUILD_SHARED )
add_definitions ( -DOPENMESHDLL )
2012-09-24 12:56:27 +00:00
2012-09-24 10:10:22 +00:00
endif ( )
2019-10-22 10:17:12 +02:00
target_link_libraries ( unittests OpenMeshCore OpenMeshTools ${ GTEST_LIBRARIES } ${ GTEST_MAIN_LIBRARIES } )
2018-04-12 15:19:53 +02:00
target_link_libraries ( unittests_customvec OpenMeshCore OpenMeshTools ${ GTEST_LIBRARIES } ${ GTEST_MAIN_LIBRARIES } )
2019-10-22 10:17:12 +02:00
target_link_libraries ( unittests_doublevec OpenMeshCore OpenMeshTools ${ GTEST_LIBRARIES } ${ GTEST_MAIN_LIBRARIES } )
2012-09-24 10:10:22 +00:00
endif ( )
2011-10-10 14:34:24 +00:00
2012-09-24 14:12:15 +00:00
if ( NOT WIN32 )
2012-02-29 10:30:21 +00:00
# Set compiler flags
2015-09-29 15:12:38 +02:00
set_target_properties ( unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long" )
2018-04-12 15:19:53 +02:00
set_target_properties ( unittests_customvec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long" )
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests_doublevec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long" )
2012-09-24 14:12:15 +00:00
else ( )
2012-02-29 10:30:21 +00:00
# Set compiler flags
2011-10-10 14:34:24 +00:00
set_target_properties ( unittests PROPERTIES COMPILE_FLAGS "" )
2018-04-12 17:53:54 +02:00
set_target_properties ( unittests_customvec PROPERTIES COMPILE_FLAGS "" )
2019-10-22 10:17:12 +02:00
set_target_properties ( unittests_doublevec PROPERTIES COMPILE_FLAGS "" )
2012-09-24 14:12:15 +00:00
endif ( )
if ( OPENMESH_BUILD_SHARED )
2012-09-24 12:56:27 +00:00
2012-09-24 14:12:15 +00:00
#-------- copy dlls to unittests --------
SET ( OPENMESH_TARGETS "OpenMeshTools" "OpenMeshCore" )
foreach ( TAR ${ OPENMESH_TARGETS } )
add_custom_command ( TARGET unittests POST_BUILD
C O M M A N D " $ { C M A K E _ C O M M A N D } " - E c o p y
" $ < T A R G E T _ F I L E : $ { T A R } > "
" $ { C M A K E _ B I N A R Y _ D I R } / U n i t t e s t s / $ < T A R G E T _ F I L E _ N A M E : $ { T A R } > "
C O M M E N T " C o p y i n g O p e n M e s h t a r g e t s t o u n i t t e s t s d i r e c t o r y " )
2018-04-12 15:19:53 +02:00
add_custom_command ( TARGET unittests_customvec POST_BUILD
C O M M A N D " $ { C M A K E _ C O M M A N D } " - E c o p y
" $ < T A R G E T _ F I L E : $ { T A R } > "
" $ { C M A K E _ B I N A R Y _ D I R } / U n i t t e s t s / $ < T A R G E T _ F I L E _ N A M E : $ { T A R } > "
C O M M E N T " C o p y i n g O p e n M e s h t a r g e t s t o u n i t t e s t s d i r e c t o r y " )
2019-10-22 10:17:12 +02:00
add_custom_command ( TARGET unittests_doublevec POST_BUILD
C O M M A N D " $ { C M A K E _ C O M M A N D } " - E c o p y
" $ < T A R G E T _ F I L E : $ { T A R } > "
" $ { C M A K E _ B I N A R Y _ D I R } / U n i t t e s t s / $ < T A R G E T _ F I L E _ N A M E : $ { T A R } > "
C O M M E N T " C o p y i n g O p e n M e s h t a r g e t s t o u n i t t e s t s d i r e c t o r y " )
2012-09-24 14:12:15 +00:00
endforeach ( TAR )
endif ( )
2011-10-10 14:34:24 +00:00
2020-12-07 14:06:26 +01:00
vci_copy_after_build ( unittests ${ CMAKE_CURRENT_SOURCE_DIR } /TestFiles ${ CMAKE_BINARY_DIR } /Unittests/ )
vci_copy_after_build ( unittests_customvec ${ CMAKE_CURRENT_SOURCE_DIR } /TestFiles ${ CMAKE_BINARY_DIR } /Unittests/ )
vci_copy_after_build ( unittests_doublevec ${ CMAKE_CURRENT_SOURCE_DIR } /TestFiles ${ CMAKE_BINARY_DIR } /Unittests/ )
2011-09-01 09:28:38 +00:00
2012-02-23 14:00:41 +00:00
add_test ( NAME AllTestsIn_OpenMesh_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests" )
2018-04-16 16:18:59 +02:00
add_test ( NAME AllTestsIn_OpenMesh_tests_with_minimal_vector WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests_customvec" )
2019-10-22 10:17:12 +02:00
add_test ( NAME AllTestsIn_OpenMesh_tests_with_double_vector WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests_doublevec" )
2012-02-23 14:00:41 +00:00
2012-02-29 10:30:21 +00:00
else ( GTEST_FOUND )
2017-01-11 08:13:59 +01:00
message ( STATUS "Google testing framework was not found, unittests disabled." )
2012-02-29 10:30:21 +00:00
endif ( GTEST_FOUND )
endif ( )