Upgrade to version 0.3.21
[platform/upstream/openblas.git] / utest / CMakeLists.txt
1 include_directories(${PROJECT_SOURCE_DIR})
2 include_directories(${PROJECT_BINARY_DIR})
3
4 if (MSVC AND "${CMAKE_C_COMPILER_ID}" MATCHES Clang)
5   set(OpenBLAS_utest_src utest_main2.c)
6 else ()
7   set(OpenBLAS_utest_src
8     utest_main.c
9     test_min.c
10     test_amax.c
11     test_ismin.c
12     test_rotmg.c
13     test_rot.c
14     test_axpy.c
15     test_dsdot.c
16     test_dnrm2.c
17     test_swap.c
18   )
19 endif ()
20
21 # crashing on travis cl with an error code suggesting resource not found
22 if (NOT MSVC)
23 set(OpenBLAS_utest_src
24   ${OpenBLAS_utest_src}
25   test_dotu.c
26   )
27 endif ()
28
29 # known to hang with the native Windows and Android threads
30 # FIXME needs checking if this works on any of the other platforms
31 if (OS_CYGWIN_NT OR OS_LINUX)
32 if (NOT USE_OPENMP)
33 set(OpenBLAS_utest_src
34   ${OpenBLAS_utest_src}
35   test_fork.c
36   )
37 endif()
38 set(OpenBLAS_utest_src
39   ${OpenBLAS_utest_src}
40   test_post_fork.c
41   )
42 endif()
43
44 if (NOT NO_LAPACK)
45 set(OpenBLAS_utest_src
46   ${OpenBLAS_utest_src}
47   test_potrs.c
48   )
49 if (NOT NO_CBLAS AND NOT NO_LAPACKE)
50 set(OpenBLAS_utest_src
51   ${OpenBLAS_utest_src}
52   test_kernel_regress.c
53   )
54 endif()
55 endif()
56
57 set(OpenBLAS_utest_bin openblas_utest)
58 add_executable(${OpenBLAS_utest_bin} ${OpenBLAS_utest_src})
59
60 target_link_libraries(${OpenBLAS_utest_bin} ${OpenBLAS_LIBNAME})
61
62 if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX"  )
63 target_link_libraries(${OpenBLAS_utest_bin} m)
64 endif()
65
66 if (${CMAKE_SYSTEM_NAME} STREQUAL "WindowsStore")
67 set_target_properties( ${OpenBLAS_utest_bin} PROPERTIES COMPILE_DEFINITIONS "_CRT_SECURE_NO_WARNINGS")
68 endif()
69
70 #Set output for utest
71 set_target_properties( ${OpenBLAS_utest_bin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
72 foreach (OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
73   string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG )
74   set_target_properties( ${OpenBLAS_utest_bin} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_CURRENT_BINARY_DIR})
75 endforeach()
76
77 if (MSVC AND BUILD_SHARED_LIBS)
78 add_custom_command(TARGET ${OpenBLAS_utest_bin}
79           POST_BUILD
80           COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/lib/${CMAKE_CFG_INTDIR}/${OpenBLAS_LIBNAME}.dll ${CMAKE_CURRENT_BINARY_DIR}/.
81 )
82 endif()
83
84 add_test(${OpenBLAS_utest_bin} ${CMAKE_CURRENT_BINARY_DIR}/${OpenBLAS_utest_bin})