From 6945e3ad520af410572b272d5ebc01e87055a030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6bius?= Date: Wed, 29 Feb 2012 10:30:21 +0000 Subject: [PATCH] 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 --- src/Unittests/CMakeLists.txt | 38 +++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index f4899061..fa64cad7 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -5,10 +5,15 @@ include_directories ( ${CMAKE_CURRENT_SOURCE_DIR} ) -# Search for gtest headers and libraries -find_package(GoogleTest) +if ( NOT DEFINED OPENMESH_BUILD_UNIT_TESTS) + 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() @@ -19,28 +24,28 @@ if(GTEST_FOUND) # Create new target named unittests_hexmeshing add_executable(unittests unittests.cc) - if ( NOT WIN32) + if ( NOT WIN32) # Link against all necessary libraries 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) else() - # Link against all necessary libraries + # Link against all necessary libraries target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) - endif() + endif() - if ( NOT WIN32 ) - # Set compiler flags + if ( NOT WIN32 ) + # Set compiler flags set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long") - else() - # Set compiler flags + else() + # Set compiler 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 # RUNTIME_OUTPUT_DIRECTORY directly here add_custom_command (TARGET unittests POST_BUILD @@ -48,12 +53,13 @@ if(GTEST_FOUND) copy_if_different ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/unittests.exe ${CMAKE_BINARY_DIR}/Unittests/unittests.exe) - endif() + endif() 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") -else(GTEST_FOUND) - message("Google testing framework was not found!") -endif(GTEST_FOUND) + else(GTEST_FOUND) + message("Google testing framework was not found!") + endif(GTEST_FOUND) +endif()