CMakeLists.txt 2.06 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
include (ACGCommon)

include_directories (
  ..
  ${CMAKE_CURRENT_SOURCE_DIR}
)

# Search for gtest headers and libraries
find_package(GoogleTest)

if(GTEST_FOUND)
12 13

    enable_testing()
14 15 16
   
    # Set correct include paths so that the compiler can find the headers
    include_directories(${GTEST_INCLUDE_DIRS})
Jan Möbius's avatar
Jan Möbius committed
17 18
    # set additional link directories
    link_directories(${GTEST_LIBRARY_DIR} )
19
    # Create new target named unittests_hexmeshing
20
    add_executable(unittests unittests.cc)
Jan Möbius's avatar
Jan Möbius committed
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
	
	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_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests)
	
    else()
	  # Link against all necessary libraries
      target_link_libraries(unittests OpenMeshCore OpenMeshTools ${GTEST_LIBRARIES} ${GTEST_MAIN_LIBRARIES}) 
	endif()
	

    
	if ( NOT WIN32 )
	  # Set compiler flags
      set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long")
	else()
	  # Set compiler flags
      set_target_properties(unittests PROPERTIES COMPILE_FLAGS "" )

	  # 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
                          COMMAND ${CMAKE_COMMAND} -E
                                  copy_if_different
                                    ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/unittests.exe
                                    ${CMAKE_BINARY_DIR}/Unittests/unittests.exe)
	endif()
	
53 54
    acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/)

55 56
    add_test(NAME AllTestsIn_OpenMesh_tests WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Unittests" COMMAND "${CMAKE_BINARY_DIR}/Unittests/unittests")

57 58 59
else(GTEST_FOUND)
    message("Google testing framework was not found!")
endif(GTEST_FOUND)