test/CMakeLists.txt
author Alpar Juttner <alpar@cs.elte.hu>
Fri, 15 Apr 2011 09:40:17 +0200
changeset 1062 1f1328691a07
parent 1044 66156a3498ea
child 1065 b522385b2a0d
child 1066 f9e3f73e17f1
child 1069 b1b534ddb539
permissions -rw-r--r--
Also search for coin libs under ${COIN_ROOT_DIR}/lib/coin (#419)
     1 INCLUDE_DIRECTORIES(
     2   ${PROJECT_SOURCE_DIR}
     3   ${PROJECT_BINARY_DIR}
     4 )
     5 
     6 LINK_DIRECTORIES(
     7   ${PROJECT_BINARY_DIR}/lemon
     8 )
     9 
    10 SET(TEST_WITH_VALGRIND "NO" CACHE STRING
    11   "Run the test with valgrind (YES/NO).")
    12 SET(VALGRIND_FLAGS "" CACHE STRING "Valgrind flags used by the tests.")
    13 
    14 SET(TESTS
    15   adaptors_test
    16   bfs_test
    17   circulation_test
    18   connectivity_test
    19   counter_test
    20   dfs_test
    21   digraph_test
    22   dijkstra_test
    23   dim_test
    24   edge_set_test
    25   error_test
    26   euler_test
    27   gomory_hu_test
    28   graph_copy_test
    29   graph_test
    30   graph_utils_test
    31   hao_orlin_test
    32   heap_test
    33   kruskal_test
    34   maps_test
    35   matching_test
    36   min_cost_arborescence_test
    37   min_cost_flow_test
    38   path_test
    39   preflow_test
    40   radix_sort_test
    41   random_test
    42   suurballe_test
    43   time_measure_test
    44   unionfind_test
    45 )
    46 
    47 IF(LEMON_HAVE_LP)
    48   IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    49     ADD_EXECUTABLE(lp_test lp_test.cc)
    50   ELSE()
    51     ADD_EXECUTABLE(lp_test EXCLUDE_FROM_ALL lp_test.cc)
    52   ENDIF()
    53 
    54   SET(LP_TEST_LIBS lemon)
    55 
    56   IF(LEMON_HAVE_GLPK)
    57     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
    58   ENDIF()
    59   IF(LEMON_HAVE_CPLEX)
    60     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
    61   ENDIF()
    62   IF(LEMON_HAVE_CLP)
    63     SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${COIN_CLP_LIBRARIES})
    64   ENDIF()
    65 
    66   TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
    67   ADD_TEST(lp_test lp_test)
    68   ADD_DEPENDENCIES(check lp_test)
    69 
    70   IF(WIN32 AND LEMON_HAVE_GLPK)
    71     GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
    72     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    73     ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
    74       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
    75       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
    76       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    77     )
    78   ENDIF()
    79 
    80   IF(WIN32 AND LEMON_HAVE_CPLEX)
    81     GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
    82     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    83     ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
    84       COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
    85     )
    86   ENDIF()
    87 ENDIF()
    88 
    89 IF(LEMON_HAVE_MIP)
    90   IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
    91     ADD_EXECUTABLE(mip_test mip_test.cc)
    92   ELSE()
    93     ADD_EXECUTABLE(mip_test EXCLUDE_FROM_ALL mip_test.cc)
    94   ENDIF()
    95 
    96   SET(MIP_TEST_LIBS lemon)
    97 
    98   IF(LEMON_HAVE_GLPK)
    99     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
   100   ENDIF()
   101   IF(LEMON_HAVE_CPLEX)
   102     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
   103   ENDIF()
   104   IF(LEMON_HAVE_CBC)
   105     SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${COIN_CBC_LIBRARIES})
   106   ENDIF()
   107 
   108   TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
   109   ADD_TEST(mip_test mip_test)
   110   ADD_DEPENDENCIES(check mip_test)
   111 
   112   IF(WIN32 AND LEMON_HAVE_GLPK)
   113     GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
   114     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
   115     ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
   116       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
   117       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
   118       COMMAND ${CMAKE_COMMAND} -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
   119     )
   120   ENDIF()
   121 
   122   IF(WIN32 AND LEMON_HAVE_CPLEX)
   123     GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
   124     GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
   125     ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
   126       COMMAND ${CMAKE_COMMAND} -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
   127     )
   128   ENDIF()
   129 ENDIF()
   130 
   131 FOREACH(TEST_NAME ${TESTS})
   132   IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
   133     ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
   134   ELSE()
   135     ADD_EXECUTABLE(${TEST_NAME} EXCLUDE_FROM_ALL ${TEST_NAME}.cc)
   136   ENDIF()
   137   TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)
   138     IF(TEST_WITH_VALGRIND)
   139       ADD_TEST(${TEST_NAME}
   140         valgrind --error-exitcode=1 ${VALGRIND_FLAGS}
   141         ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME} )
   142     ELSE()
   143       ADD_TEST(${TEST_NAME} ${TEST_NAME})
   144     ENDIF()
   145   ADD_DEPENDENCIES(check ${TEST_NAME})
   146 ENDFOREACH()