Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Try to autodetect cppunit and only build the tests if we find it.

Removed the (now redundant) link_directories command. Also decided that tests probably shouldn't be installed so I took out the install command from the test function.
  • Loading branch information...
commit 09be4b68da7bc79d975a189beb578b40eb2dae4c 1 parent 7ce09d7
Vilya Harvey authored

Showing 1 changed file with 17 additions and 7 deletions. Show diff stats Hide diff stats

  1. +17 7 CMakeLists.txt
24 CMakeLists.txt
@@ -9,6 +9,16 @@ include(FindOpenGL)
9 9 include(FindOpenMP)
10 10 include(FindTIFF)
11 11
  12 +# There's no ready-made CMake module for setting up cppunit, so it's DIY time...
  13 +find_library(CPPUNIT_LIBRARY cppunit)
  14 +if (CPPUNIT_LIBRARY STREQUAL "CPPUNIT_LIBRARY-NOTFOUND")
  15 + message(WARNING "Unable to find cppunit. Tests won't be built.")
  16 + set(CPPUNIT_FOUND 0)
  17 +else (CPPUNIT_LIBRARY STREQUAL "CPPUNIT_LIBRARY-NOTFOUND")
  18 + message(STATUS "Found cppunit: ${CPPUNIT_LIBRARY}")
  19 + set(CPPUNIT_FOUND 1)
  20 +endif (CPPUNIT_LIBRARY STREQUAL "CPPUNIT_LIBRARY-NOTFOUND")
  21 +
12 22
13 23 # General build properties.
14 24 file(GLOB VGL_SOURCES src/*.cpp thirdparty/*.c)
@@ -24,7 +34,6 @@ include_directories(src thirdparty
24 34 ${JPEG_INCLUDE_DIR}
25 35 ${PNG_INCLUDE_DIR}
26 36 ${TIFF_INCLUDE_DIR})
27   -link_directories(/opt/local/lib)
28 37
29 38
30 39 # Helper function which creates an example program.
@@ -38,8 +47,7 @@ endfunction(example)
38 47 # Helper function which creates a test program.
39 48 function (test test_NAME)
40 49 add_executable(${test_NAME} test/${test_NAME}.cpp)
41   - target_link_libraries(${test_NAME} vgl cppunit)
42   - install(TARGETS ${test_NAME} DESTINATION bin)
  50 + target_link_libraries(${test_NAME} vgl ${CPPUNIT_LIBRARY})
43 51 add_test(NAME run-${test_NAME} COMMAND ${test_NAME})
44 52 endfunction(test)
45 53
@@ -52,13 +60,15 @@ target_link_libraries(vgl
52 60 ${JPEG_LIBRARIES}
53 61 ${PNG_LIBRARIES}
54 62 ${TIFF_LIBRARIES})
55   -install(FILES ${VGL_HEADERS} DESTINATION dist/include)
56   -install(TARGETS vgl LIBRARY DESTINATION dist/lib)
  63 +install(FILES ${VGL_HEADERS} DESTINATION include)
  64 +install(TARGETS vgl LIBRARY DESTINATION lib)
57 65
58 66
59 67 # The unit tests.
60   -enable_testing()
61   -test(test_quaternion)
  68 +if (CPPUNIT_FOUND)
  69 + enable_testing()
  70 + test(test_quaternion)
  71 +endif (CPPUNIT_FOUND)
62 72
63 73
64 74 # The example programs.

0 comments on commit 09be4b6

Please sign in to comment.
Something went wrong with that request. Please try again.