chiark / gitweb /
Switch to cmake (#49)
[nlopt.git] / test / CMakeLists.txt
1 add_custom_target (tests)
2
3 # have to add timer.c and mt19937ar.c as symbols are declared extern
4 add_executable (testopt EXCLUDE_FROM_ALL testfuncs.c testfuncs.h testopt.cpp ${CMAKE_SOURCE_DIR}/util/timer.c ${CMAKE_SOURCE_DIR}/util/mt19937ar.c)
5 target_link_libraries (testopt ${nlopt_lib})
6 add_dependencies (tests testopt)
7
8 foreach (algo_index RANGE 29)# 42
9   foreach (obj_index RANGE 1)# 21
10     set (enable_ TRUE)
11     # cxx stogo
12     if (NOT WITH_CXX)
13       if (algo_index STREQUAL 8 OR algo_index STREQUAL 9)
14         set (enable_ FALSE)
15       endif ()
16     endif ()
17     # L-BFGS
18     if (algo_index STREQUAL 10)
19       set (enable_ FALSE)
20     endif ()
21     if (enable_)
22       add_test (NAME testopt_algo${algo_index}_obj${obj_index} COMMAND testopt -a ${algo_index} -o ${obj_index})
23     endif ()
24   endforeach ()
25 endforeach ()
26
27 if (NUMPY_FOUND AND PYTHONLIBS_FOUND AND (SWIG_FOUND OR (EXISTS ${CMAKE_SOURCE_DIR}/swig/nlopt-python.cpp)))
28   set (PYINSTALLCHECK_ENVIRONMENT "LD_LIBRARY_PATH=${INSTALL_DESTDIR}${INSTALL_LIB_DIR}:$ENV{LD_LIBRARY_PATH}"
29                                   "PYTHONPATH=${INSTALL_DESTDIR}${CMAKE_INSTALL_PREFIX}/${PYTHON_MODULE_PATH}${PATH_SEP}$ENV{PYTHONPATH}"
30     )
31   add_test (NAME test_std_python COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test_std.py)
32   set_tests_properties (test_std_python PROPERTIES ENVIRONMENT "${PYINSTALLCHECK_ENVIRONMENT}")
33 endif ()