2023-11-26 13:20:54 +01:00
include ( VCICommon )
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
u n i t t e s t s _ t r a i t s . 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 _ 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
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
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
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
2022-02-23 10:14:10 +01:00
)
2023-11-26 13:20:54 +01:00
if ( NOT DEFINED OPENMESH_BUILD_UNIT_TESTS )
set ( OPENMESH_BUILD_UNIT_TESTS false CACHE BOOL "Enable or disable unit test builds in OpenMesh." )
2012-02-29 10:30:21 +00:00
endif ( )
2011-09-01 09:28:38 +00:00
2023-11-26 13:20:54 +01:00
if ( OPENMESH_BUILD_UNIT_TESTS )
# Fetch Gtest from github
include ( FetchContent )
FetchContent_Declare (
g o o g l e t e s t
G I T _ R E P O S I T O R Y h t t p s : / / g i t h u b . c o m / g o o g l e / g o o g l e t e s t . g i t
G I T _ T A G f 8 d 7 d 7 7 c 0 6 9 3 6 3 1 5 2 8 6 e b 5 5 f 8 d e 2 2 c d 2 3 c 1 8 8 5 7 1 # v1.14.0
F I N D _ P A C K A G E _ A R G S N A M E S G T e s t
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
set ( gtest_force_shared_crt ON CACHE BOOL "" FORCE )
FetchContent_MakeAvailable ( googletest )
enable_testing ( )
find_package ( Eigen3 )
# Set correct include paths so that the compiler can find the headers
include_directories ( ${ GTEST_INCLUDE_DIRS } )
# Set additional link directories
link_directories ( ${ GTEST_LIBRARY_DIR } )
if ( TARGET Eigen3::Eigen )
add_definitions ( -DENABLE_EIGEN3_TEST )
link_libraries ( Eigen3::Eigen )
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" )
endif ( )
# Create new target named unittests_hexmeshing
# Create unittest executable
vci_add_executable ( unittests ${ UNITTEST_SRC } )
vci_add_executable ( unittests_customvec ${ UNITTEST_SRC } )
vci_add_executable ( unittests_doublevec ${ UNITTEST_SRC } )
target_compile_definitions ( unittests_customvec PRIVATE TEST_CUSTOM_TRAITS )
target_compile_definitions ( unittests_doublevec PRIVATE TEST_DOUBLE_TRAITS )
# For the unittest we don't want the install rpath as set by vci_add_executable
set_target_properties ( unittests PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
set_target_properties ( unittests_customvec PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
set_target_properties ( unittests_doublevec PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
# Set output directory to ${BINARY_DIR}/Unittests
set ( OUTPUT_DIR "${CMAKE_BINARY_DIR}/Unittests" )
set_target_properties ( unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ OUTPUT_DIR } )
set_target_properties ( unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ OUTPUT_DIR } )
set_target_properties ( unittests_doublevec PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${ OUTPUT_DIR } )
foreach ( CONFIG ${ CMAKE_CONFIGURATION_TYPES } )
string ( TOUPPER ${ CONFIG } UPCONFIG )
set_target_properties ( unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY_ ${ UPCONFIG } ${ OUTPUT_DIR } )
set_target_properties ( unittests_customvec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_ ${ UPCONFIG } ${ OUTPUT_DIR } )
set_target_properties ( unittests_doublevec PROPERTIES RUNTIME_OUTPUT_DIRECTORY_ ${ UPCONFIG } ${ OUTPUT_DIR } )
endforeach ( )
if ( NOT WIN32 )
# Link against all necessary libraries
target_link_libraries ( unittests OpenMeshCore OpenMeshTools GTest::gtest GTest::gtest_main pthread )
target_link_libraries ( unittests_customvec OpenMeshCore OpenMeshTools GTest::gtest GTest::gtest_main pthread )
target_link_libraries ( unittests_doublevec OpenMeshCore OpenMeshTools GTest::gtest GTest::gtest_main pthread )
else ( )
# Link against all necessary libraries
target_link_libraries ( unittests OpenMeshCore OpenMeshTools GTest::gtest GTest::gtest_main )
target_link_libraries ( unittests_customvec OpenMeshCore OpenMeshTools GTest::gtest GTest::gtest_main )
target_link_libraries ( unittests_doublevec OpenMeshCore OpenMeshTools GTest::gtest GTest::gtest_main )
if ( OPENMESH_BUILD_SHARED )
add_definitions ( -DOPENMESHDLL )
2012-09-24 14:12:15 +00:00
endif ( )
2023-11-26 13:20:54 +01:00
endif ( )
if ( NOT WIN32 )
# Set compiler flags
set_target_properties ( unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long" )
set_target_properties ( unittests_customvec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long" )
set_target_properties ( unittests_doublevec PROPERTIES COMPILE_FLAGS "-g -pedantic -Wno-long-long" )
else ( )
# Set compiler flags
set_target_properties ( unittests PROPERTIES COMPILE_FLAGS "" )
set_target_properties ( unittests_customvec PROPERTIES COMPILE_FLAGS "" )
set_target_properties ( unittests_doublevec PROPERTIES COMPILE_FLAGS "" )
endif ( )
if ( OPENMESH_BUILD_SHARED )
# 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 " )
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 " )
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 " )
endforeach ( TAR )
endif ( )
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/ )
add_test ( NAME AllTestsIn_OpenMesh_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests" )
add_test ( NAME AllTestsIn_OpenMesh_tests_with_minimal_vector WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests_customvec" )
add_test ( NAME AllTestsIn_OpenMesh_tests_with_double_vector WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests_doublevec" )
2012-02-29 10:30:21 +00:00
endif ( )