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} )
|
2011-09-01 09:28:38 +00:00
|
|
|
# Create new target named unittests_hexmeshing
|
2012-02-23 14:00:41 +00:00
|
|
|
add_executable(unittests unittests.cc)
|
2011-10-10 14:34:24 +00:00
|
|
|
|
2012-09-24 10:10:22 +00:00
|
|
|
if ( NOT WIN32)
|
2011-10-10 14:34:24 +00:00
|
|
|
# Link against all necessary libraries
|
|
|
|
|
target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
|
|
|
|
|
|
2012-02-29 10:30:21 +00:00
|
|
|
# Set output directory to ${BINARY_DIR}/Unittests
|
2011-10-10 14:34:24 +00:00
|
|
|
set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests)
|
|
|
|
|
|
|
|
|
|
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 )
|
|
|
|
|
#!!!! Experimental Feature!!!
|
|
|
|
|
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-02-29 10:30:21 +00:00
|
|
|
if ( NOT WIN32 )
|
|
|
|
|
# Set compiler flags
|
2011-10-10 14:34:24 +00:00
|
|
|
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long")
|
2012-02-29 10:30:21 +00:00
|
|
|
else()
|
|
|
|
|
# Set compiler flags
|
2011-10-10 14:34:24 +00:00
|
|
|
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" )
|
|
|
|
|
|
2012-09-24 12:56:27 +00:00
|
|
|
#-------- copy exe file to "Build" directory --------
|
2011-10-10 14:34:24 +00:00
|
|
|
# Visual studio will create this file in a subdirectory so we can't use
|
|
|
|
|
# RUNTIME_OUTPUT_DIRECTORY directly here
|
|
|
|
|
add_custom_command (TARGET unittests POST_BUILD
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E
|
|
|
|
|
copy_if_different
|
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/unittests.exe
|
|
|
|
|
${CMAKE_BINARY_DIR}/Unittests/unittests.exe)
|
2012-09-24 10:10:22 +00:00
|
|
|
endif()
|
2012-09-24 12:56:27 +00:00
|
|
|
if ( OPENMESH_BUILD_SHARED )
|
|
|
|
|
#!!!! Experimental Feature!!!
|
|
|
|
|
|
|
|
|
|
#-------- 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()
|