Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 78 lines (66 sloc) 2.626 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
# Copyright (c) 2010 Daniel Pfeifer
# 2010-2012, Stefan Eilemann <eile@eyescale.ch>
#
# Change this number when adding tests to force a CMake run: 0

option(EQUALIZER_BUILD_TESTS "Build Equalizer unit tests." ON)
option(EQUALIZER_RUN_GPU_TESTS "Run Equalizer unit tests using a GPU." OFF)
if(NOT EQUALIZER_BUILD_TESTS)
  return()
endif(NOT EQUALIZER_BUILD_TESTS)

if(NOT WIN32) # tests want to be with DLLs on Windows - no rpath
  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Equalizer_BINARY_DIR}/tests)
endif()

file(GLOB COMPOSITOR_IMAGES compositor/*.rgb)
file(GLOB TEST_CONFIGS server/reliability/*.eqc)
file(COPY compressor/images ${CMAKE_SOURCE_DIR}/examples/configs
  ${COMPOSITOR_IMAGES} ${TEST_CONFIGS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_SOURCE_DIR}/examples/include # test need tclap from examples
  )

if(GLEW_MX_FOUND)
  include_directories(BEFORE SYSTEM ${GLEW_MX_INCLUDE_DIRS})
endif()

file(GLOB_RECURSE TEST_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)

set(ALL_TESTS)
foreach(FILE ${TEST_FILES})
  set(THIS_BUILD ON)
  if(EQ_BIG_ENDIAN)
    if( ${FILE} MATCHES "compressor/image.cpp" OR
        ${FILE} MATCHES "compositor/test.cpp" )
      set(THIS_BUILD OFF)
    endif()
  endif()

  if(THIS_BUILD)
    string(REGEX REPLACE ".cpp" "" NAME ${FILE})
    string(REGEX REPLACE "[./]" "_" NAME ${NAME})
    source_group(\\ FILES ${FILE})
    add_executable(${NAME} ${FILE})
    set_target_properties(${NAME} PROPERTIES FOLDER "Tests")

    target_link_libraries(${NAME} lib_Equalizer_shared)
    if(${NAME} MATCHES "server_.*")
      target_link_libraries(${NAME} lib_EqualizerServer_shared)
    endif()
    if(${NAME} MATCHES "fabric_.*")
      target_link_libraries(${NAME} lib_EqualizerFabric_shared)
    endif()
    if(${NAME} MATCHES "sequel_.*")
      target_link_libraries(${NAME} lib_Sequel_shared)
    endif()

    if(EQUALIZER_RUN_GPU_TESTS OR NOT ${NAME} MATCHES ".*_gpu")
      get_target_property(EXECUTABLE ${NAME} LOCATION)
      STRING(REGEX REPLACE "\\$\\(.*\\)" "\${CTEST_CONFIGURATION_TYPE}"
             EXECUTABLE "${EXECUTABLE}")

      add_test(${NAME} ${EXECUTABLE})
      if(APPLE)
        set_property(TEST ${NAME} PROPERTY ENVIRONMENT
          "DYLD_LIBRARY_PATH=${LUNCHBOX_LIBRARY_DIRS}:$ENV{DYLD_LIBRARY_PATH}"
          )
      endif()
    endif()
    list(APPEND ALL_TESTS ${NAME})
  endif()
endforeach(FILE ${TEST_FILES})

# workaround bug that tests won't get built
add_custom_target(tests COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS ${ALL_TESTS})
set_target_properties(tests PROPERTIES FOLDER "Tests")
Something went wrong with that request. Please try again.