Added flag to make builds of tests optional via cmake flag
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@541 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
@@ -5,10 +5,15 @@ include_directories (
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Search for gtest headers and libraries
|
if ( NOT DEFINED OPENMESH_BUILD_UNIT_TESTS)
|
||||||
find_package(GoogleTest)
|
set( OPENMESH_BUILD_UNIT_TESTS false CACHE BOOL "Enable or disable unit test builds in OpenMesh." )
|
||||||
|
endif()
|
||||||
|
|
||||||
if(GTEST_FOUND)
|
if ( OPENMESH_BUILD_UNIT_TESTS )
|
||||||
|
# Search for gtest headers and libraries
|
||||||
|
find_package(GoogleTest)
|
||||||
|
|
||||||
|
if(GTEST_FOUND)
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
@@ -19,28 +24,28 @@ if(GTEST_FOUND)
|
|||||||
# Create new target named unittests_hexmeshing
|
# Create new target named unittests_hexmeshing
|
||||||
add_executable(unittests unittests.cc)
|
add_executable(unittests unittests.cc)
|
||||||
|
|
||||||
if ( NOT WIN32)
|
if ( NOT WIN32)
|
||||||
# Link against all necessary libraries
|
# Link against all necessary libraries
|
||||||
target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
|
target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES} pthread)
|
||||||
|
|
||||||
# Set output directory to ${BINARY_DIR}/Unittests
|
# Set output directory to ${BINARY_DIR}/Unittests
|
||||||
set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests)
|
set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests)
|
||||||
|
|
||||||
else()
|
else()
|
||||||
# Link against all necessary libraries
|
# Link against all necessary libraries
|
||||||
target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
|
target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ( NOT WIN32 )
|
if ( NOT WIN32 )
|
||||||
# Set compiler flags
|
# Set compiler flags
|
||||||
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long")
|
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long")
|
||||||
else()
|
else()
|
||||||
# Set compiler flags
|
# Set compiler flags
|
||||||
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" )
|
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" )
|
||||||
|
|
||||||
# copy exe file to "Build" directory
|
# copy exe file to "Build" directory
|
||||||
# Visual studio will create this file in a subdirectory so we can't use
|
# Visual studio will create this file in a subdirectory so we can't use
|
||||||
# RUNTIME_OUTPUT_DIRECTORY directly here
|
# RUNTIME_OUTPUT_DIRECTORY directly here
|
||||||
add_custom_command (TARGET unittests POST_BUILD
|
add_custom_command (TARGET unittests POST_BUILD
|
||||||
@@ -48,12 +53,13 @@ if(GTEST_FOUND)
|
|||||||
copy_if_different
|
copy_if_different
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/unittests.exe
|
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/unittests.exe
|
||||||
${CMAKE_BINARY_DIR}/Unittests/unittests.exe)
|
${CMAKE_BINARY_DIR}/Unittests/unittests.exe)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/)
|
acg_copy_after_build(unittests ${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 WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests")
|
||||||
|
|
||||||
else(GTEST_FOUND)
|
else(GTEST_FOUND)
|
||||||
message("Google testing framework was not found!")
|
message("Google testing framework was not found!")
|
||||||
endif(GTEST_FOUND)
|
endif(GTEST_FOUND)
|
||||||
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user