2011-09-01 09:28:38 +00:00
|
|
|
include (ACGCommon)
|
|
|
|
|
|
|
|
|
|
include_directories (
|
|
|
|
|
..
|
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
|
)
|
|
|
|
|
|
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
|
|
|
|
|
find_package(GoogleTest)
|
|
|
|
|
|
|
|
|
|
if(GTEST_FOUND)
|
2012-02-23 14:00:41 +00:00
|
|
|
|
|
|
|
|
enable_testing()
|
2011-09-01 09:28:38 +00:00
|
|
|
|
|
|
|
|
# Set correct include paths so that the compiler can find the headers
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
|
|
|
|
|
add_definitions( /D _VARIADIC_MAX=10 )
|
|
|
|
|
endif()
|
|
|
|
|
|
2011-09-01 09:28:38 +00:00
|
|
|
# Create new target named unittests_hexmeshing
|
2013-09-20 14:21:08 +00:00
|
|
|
FILE(GLOB UNITTEST_SRC *.cc)
|
2015-06-16 10:57:51 +00:00
|
|
|
# Create unittest executable
|
|
|
|
|
acg_add_executable(unittests ${UNITTEST_SRC})
|
|
|
|
|
|
|
|
|
|
# For the unittest we don't want the install rpath as set by acg_add_executable
|
|
|
|
|
set_target_properties ( unittests PROPERTIES BUILD_WITH_INSTALL_RPATH 0 )
|
|
|
|
|
|
2015-06-18 11:23:28 +00:00
|
|
|
# Set output directory to ${BINARY_DIR}/Unittests
|
|
|
|
|
set (OUTPUT_DIR "${CMAKE_BINARY_DIR}/Unittests")
|
|
|
|
|
set_target_properties(unittests 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})
|
|
|
|
|
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)
|
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()
|
2011-10-10 14:34:24 +00:00
|
|
|
target_link_libraries(unittests 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")
|
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 "" )
|
|
|
|
|
|
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
|
|
|
|
|
COMMAND "${CMAKE_COMMAND}" -E copy
|
|
|
|
|
"$<TARGET_FILE:${TAR}>"
|
|
|
|
|
"${CMAKE_BINARY_DIR}/Unittests/$<TARGET_FILE_NAME:${TAR}>"
|
|
|
|
|
COMMENT "Copying OpenMesh targets to unittests directory")
|
|
|
|
|
endforeach(TAR)
|
|
|
|
|
endif()
|
2011-10-10 14:34:24 +00:00
|
|
|
|
2011-09-01 09:28:38 +00:00
|
|
|
acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/)
|
|
|
|
|
|
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")
|
|
|
|
|
|
2012-02-29 10:30:21 +00:00
|
|
|
else(GTEST_FOUND)
|
|
|
|
|
message("Google testing framework was not found!")
|
|
|
|
|
endif(GTEST_FOUND)
|
|
|
|
|
endif()
|