CMakeLists.txt 5.05 KB
Newer Older
Andy Cedilnik's avatar
Andy Cedilnik committed
1
## Copyright 2003 Sandia Coporation
2 3 4 5
## Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
## the U.S. Government retains certain rights in this software.
##
## This source code is released under the New BSD License.
Andy Cedilnik's avatar
Andy Cedilnik committed
6 7
#

8
IF (ICET_USE_OPENGL AND NOT ICET_USE_OFFSCREEN_EGL)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
  SET(ICET_OPENGL_WINDOW_LIBRARY GLUT
    CACHE STRING
    "The name of the library the IceT tests will use to create windows for
OpenGL contexts. Supported values are GLUT and GLFW."
    )
  SET_PROPERTY(CACHE ICET_OPENGL_WINDOW_LIBRARY
    PROPERTY STRINGS GLUT GLFW
    )
  MARK_AS_ADVANCED(ICET_OPENGL_WINDOW_LIBRARY)
  IF (ICET_OPENGL_WINDOW_LIBRARY STREQUAL GLUT)
    FIND_PACKAGE(GLUT)
    IF (GLUT_FOUND)
      INCLUDE_DIRECTORIES(${GLUT_INCLUDE_DIR})
      SET(ICET_TESTS_USE_OPENGL 1)
      SET(ICET_TESTS_USE_GLUT 1)
    ELSE (GLUT_FOUND)
25
      MESSAGE(STATUS "Cannot find GLUT library. OpenGL tests disabled.")
26 27 28 29 30 31 32 33 34 35 36 37 38
    ENDIF (GLUT_FOUND)
  ELSEIF (ICET_OPENGL_WINDOW_LIBRARY STREQUAL GLFW)
    FIND_PACKAGE(GLFW)
    IF (GLFW_FOUND)
      INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIR})
      SET(ICET_TESTS_USE_OPENGL 1)
      SET(ICET_TESTS_USE_GLFW 1)
    ELSE (GLFW_FOUND)
      MESSAGE(WARNING "Cannot find GLFW library. OpenGL tests disabled.")
    ENDIF (GLFW_FOUND)
  ELSE ()
    MESSAGE(SEND_ERROR "Invalid value for ICET_OPENGL_WINDOW_LIBRARY: ${ICET_OPENGL_WINDOW_LIBRARY}")
  ENDIF ()
39
ENDIF ()
40 41

IF (NOT ICET_TESTS_USE_OPENGL)
42
  MESSAGE(STATUS "Most tests require ICET_USE_OPENGL and GLUT or GLFW. Those tests are disabled.")
43 44
ENDIF (NOT ICET_TESTS_USE_OPENGL)

45
SET(IceTTestSrcs
46
  BackgroundCorrect.c
47
  CompressionSize.c
48
  FloatingViewport.c
49
  Interlace.c
50
  MaxImageSplit.c
51
  OddImageSizes.c
52
  OddProcessCounts.c
53
  PreRender.c
54
  RadixkrUnitTests.c
55
  RadixkUnitTests.c
56
  RenderEmpty.c
57
  SimpleTiming.c
58
  SparseImageCopy.c
59
  )
Andy Cedilnik's avatar
Andy Cedilnik committed
60

61 62 63 64 65 66 67
SET(IceTOpenGLTestSrcs
  BlankTiles.c
  BoundsBehindViewer.c
  DisplayNoDraw.c
  RandomTransform.c
  SimpleExample.c
  )
68

69 70 71 72
SET(UTIL_SRCS
  test_common.c
  ppm.c
  )
Andy Cedilnik's avatar
Andy Cedilnik committed
73

74 75
SET(TEST_HEADERS
  test_codes.h
76
  test_util.h
77 78
  test_mpi.h
  test_mpi_opengl.h
79 80 81 82 83
  )
SET_SOURCE_FILES_PROPERTIES(${TEST_HEADERS}
  PROPERTIES HEADER_ONLY TRUE
  )

84
CONFIGURE_FILE(
85 86
  ${CMAKE_CURRENT_SOURCE_DIR}/test_config.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/test_config.h
87 88 89 90 91 92
  )

INCLUDE_DIRECTORIES(
  ${CMAKE_CURRENT_SOURCE_DIR}
  ${CMAKE_CURRENT_BINARY_DIR}
  )
93

Andy Cedilnik's avatar
Andy Cedilnik committed
94
IF (ICET_MPIRUN_EXE)
95
  SET(PRE_TEST_FLAGS ${ICET_MPIRUN_EXE} ${ICET_MPI_NUMPROC_FLAG} ${ICET_MPI_MAX_NUMPROCS} ${ICET_MPI_PREFLAGS})
Andy Cedilnik's avatar
Andy Cedilnik committed
96 97 98
  SET(POST_TEST_FLAGS ${ICET_MPI_POSTFLAGS})
ENDIF (ICET_MPIRUN_EXE)

99
SET(ICET_TEST_FLAGS "" CACHE STRING "Arguments given to the test program.  These are given between the test executable and the name of the test.  Run the test executable with the -h flag to see what is available.")
Andy Cedilnik's avatar
Andy Cedilnik committed
100 101 102
MARK_AS_ADVANCED(ICET_TEST_FLAGS)
SEPARATE_ARGUMENTS(ICET_TEST_FLAGS)

103 104 105 106 107 108 109 110 111 112 113
CREATE_TEST_SOURCELIST(Tests icetTests_mpi.c ${IceTTestSrcs}
  EXTRA_INCLUDE test_mpi.h
  FUNCTION init_mpi)

ADD_EXECUTABLE(icetTests_mpi ${Tests} ${UTIL_SRCS} ${TEST_HEADERS})
TARGET_LINK_LIBRARIES(icetTests_mpi
  IceTCore
  IceTMPI
  )

FOREACH (test ${IceTTestSrcs})
Andy Cedilnik's avatar
Andy Cedilnik committed
114
  GET_FILENAME_COMPONENT(TName ${test} NAME_WE)
115 116
  ADD_TEST(NAME IceT${TName}
    COMMAND
117
    ${PRE_TEST_FLAGS}
118
    $<TARGET_FILE:icetTests_mpi> ${ICET_TEST_FLAGS} ${TName}
119
    ${POST_TEST_FLAGS})
120 121 122 123 124 125 126 127 128
  IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.1)
    SET_TESTS_PROPERTIES(IceT${TName}
      PROPERTIES FAIL_REGULAR_EXPRESSION
      ":ERROR:;TEST NOT RUN;TEST NOT PASSED;TEST FAILED"
      )
    SET_TESTS_PROPERTIES(IceT${TName}
      PROPERTIES PASS_REGULAR_EXPRESSION "Test Passed"
      )
  ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.1)
Andy Cedilnik's avatar
Andy Cedilnik committed
129 130
ENDFOREACH(test)

131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
IF (ICET_TESTS_USE_OPENGL)
  CREATE_TEST_SOURCELIST(OpenGLTests icetTests_mpi_opengl.c ${IceTOpenGLTestSrcs}
    EXTRA_INCLUDE test_mpi_opengl.h
    FUNCTION init_mpi_opengl)

  ADD_EXECUTABLE(icetTests_mpi_opengl ${OpenGLTests} ${UTIL_SRCS} ${TEST_HEADERS})
  TARGET_LINK_LIBRARIES(icetTests_mpi_opengl
    IceTCore
    IceTMPI
    IceTGL
    )
  IF (ICET_TESTS_USE_GLUT)
    TARGET_LINK_LIBRARIES(icetTests_mpi_opengl ${GLUT_LIBRARIES})
  ENDIF (ICET_TESTS_USE_GLUT)
  IF (ICET_TESTS_USE_GLFW)
    TARGET_LINK_LIBRARIES(icetTests_mpi_opengl ${GLFW_LIBRARY})
  ENDIF (ICET_TESTS_USE_GLFW)

  FOREACH (test ${IceTOpenGLTestSrcs})
    GET_FILENAME_COMPONENT(TName ${test} NAME_WE)
    ADD_TEST(NAME IceT${TName}
      COMMAND
      ${PRE_TEST_FLAGS}
      $<TARGET_FILE:icetTests_mpi_opengl> ${ICET_TEST_FLAGS} ${TName}
      ${POST_TEST_FLAGS})
    IF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.1)
      SET_TESTS_PROPERTIES(IceT${TName}
        PROPERTIES FAIL_REGULAR_EXPRESSION
        ":ERROR:;TEST NOT RUN;TEST NOT PASSED;TEST FAILED"
        )
      SET_TESTS_PROPERTIES(IceT${TName}
        PROPERTIES PASS_REGULAR_EXPRESSION "Test Passed"
        )
    ENDIF (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.1)
  ENDFOREACH(test)
ENDIF (ICET_TESTS_USE_OPENGL)

168 169 170 171 172 173
ADD_CUSTOM_TARGET(logclean
  ${CMAKE_COMMAND} -E remove
    ${CMAKE_CURRENT_BINARY_DIR}/log.????
    ${CMAKE_CURRENT_BINARY_DIR}/*.ppm
    ${CMAKE_CURRENT_BINARY_DIR}/core.*
  )