CMakeLists.txt 5.09 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
    ENDIF (GLUT_FOUND)
  ELSEIF (ICET_OPENGL_WINDOW_LIBRARY STREQUAL GLFW)
Kenneth Moreland's avatar
Kenneth Moreland committed
28 29 30 31
    FIND_PACKAGE(glfw3)
    IF (glfw3_FOUND)
      #INCLUDE_DIRECTORIES(${GLFW_INCLUDE_DIR})
      SET(GLFW_LIBRARY glfw)
32 33
      SET(ICET_TESTS_USE_OPENGL 1)
      SET(ICET_TESTS_USE_GLFW 1)
Kenneth Moreland's avatar
Kenneth Moreland committed
34
    ELSE (glfw3_FOUND)
35
      MESSAGE(WARNING "Cannot find GLFW library. OpenGL tests disabled.")
Kenneth Moreland's avatar
Kenneth Moreland committed
36
    ENDIF (glfw3_FOUND)
37 38 39
  ELSE ()
    MESSAGE(SEND_ERROR "Invalid value for ICET_OPENGL_WINDOW_LIBRARY: ${ICET_OPENGL_WINDOW_LIBRARY}")
  ENDIF ()
40
ENDIF ()
41 42

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

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

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

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

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

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

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

Andy Cedilnik's avatar
Andy Cedilnik committed
95
IF (ICET_MPIRUN_EXE)
96
  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
97 98 99
  SET(POST_TEST_FLAGS ${ICET_MPI_POSTFLAGS})
ENDIF (ICET_MPIRUN_EXE)

100
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
101 102 103
MARK_AS_ADVANCED(ICET_TEST_FLAGS)
SEPARATE_ARGUMENTS(ICET_TEST_FLAGS)

104 105 106 107 108 109 110 111 112 113 114
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
115
  GET_FILENAME_COMPONENT(TName ${test} NAME_WE)
116 117
  ADD_TEST(NAME IceT${TName}
    COMMAND
118
    ${PRE_TEST_FLAGS}
119
    $<TARGET_FILE:icetTests_mpi> ${ICET_TEST_FLAGS} ${TName}
120
    ${POST_TEST_FLAGS})
121 122 123 124 125 126 127 128 129
  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
130 131
ENDFOREACH(test)

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 168
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)

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