chiark / gitweb /
Cleaner way to fix ctest (#144)
[nlopt.git] / test / CMakeLists.txt
index c1990fddecfd5e57027916542e02545d1705ba08..7ee60cf0ef5601d083dc1166bac876018dbe5585 100644 (file)
@@ -1,8 +1,10 @@
 add_custom_target (tests)
 
 # have to add timer.c and mt19937ar.c as symbols are declared extern
-add_executable (testopt testfuncs.c testfuncs.h testopt.cpp ${PROJECT_SOURCE_DIR}/util/timer.c ${PROJECT_SOURCE_DIR}/util/mt19937ar.c)
+add_executable (testopt testfuncs.c testfuncs.h testopt.c
+  ${PROJECT_SOURCE_DIR}/util/timer.c ${PROJECT_SOURCE_DIR}/util/mt19937ar.c ${CMAKE_SOURCE_DIR}/util/nlopt-getopt.c)
 target_link_libraries (testopt ${nlopt_lib})
+target_include_directories (testopt PRIVATE ${NLOPT_PRIVATE_INCLUDE_DIRS})
 add_dependencies (tests testopt)
 
 foreach (algo_index RANGE 29)# 42
@@ -24,6 +26,9 @@ foreach (algo_index RANGE 29)# 42
     endif ()
     if (enable_)
       add_test (NAME testopt_algo${algo_index}_obj${obj_index} COMMAND testopt -a ${algo_index} -o ${obj_index})
+      if (WIN32)
+        set_tests_properties (testopt_algo${algo_index}_obj${obj_index} PROPERTIES ENVIRONMENT "PATH=${PROJECT_BINARY_DIR}\\${CMAKE_BUILD_TYPE};$ENV{PATH}")  # to load dll
+      endif ()
     endif ()
   endforeach ()
 endforeach ()
@@ -46,4 +51,4 @@ if (GUILE_FOUND AND ((SWIG_FOUND AND SWIG_VERSION VERSION_GREATER 2.0.9) OR (EXI
     )
   add_test (NAME test_guile COMMAND ${GUILE_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/t_guile.scm)
   set_tests_properties (test_guile PROPERTIES ENVIRONMENT "${GUILECHECK_ENVIRONMENT}")
-endif ()
\ No newline at end of file
+endif ()