You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 3.9 kB

5 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. include_directories(${PROJECT_SOURCE_DIR})
  2. include_directories(${PROJECT_BINARY_DIR})
  3. if (NOT NOFORTRAN)
  4. enable_language(Fortran)
  5. endif()
  6. set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DADD${BU} -DCBLAS")
  7. if (CMAKE_Fortran_COMPILER_ID STREQUAL GNU)
  8. set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fno-tree-vectorize")
  9. endif()
  10. if(WIN32)
  11. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.ps1
  12. "$ErrorActionPreference = \"Stop\"\n"
  13. "Get-Content $args[1] | & $args[0]\n"
  14. )
  15. set(test_helper powershell -ExecutionPolicy Bypass "${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.ps1")
  16. else()
  17. FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.sh
  18. "$1 < $2\n"
  19. )
  20. set(test_helper sh "${CMAKE_CURRENT_BINARY_DIR}/test_cblas_helper.sh")
  21. endif()
  22. foreach(float_type ${FLOAT_TYPES})
  23. string(SUBSTRING ${float_type} 0 1 float_char_upper)
  24. string(TOLOWER ${float_char_upper} float_char)
  25. if (${float_char} STREQUAL "b")
  26. continue()
  27. endif()
  28. #level1
  29. if (NOT NOFORTRAN)
  30. add_executable(x${float_char}cblat1
  31. c_${float_char}blat1.f
  32. c_${float_char}blas1.c)
  33. else()
  34. add_executable(x${float_char}cblat1
  35. c_${float_char}blat1c.c
  36. c_${float_char}blas1.c)
  37. endif()
  38. target_link_libraries(x${float_char}cblat1 ${OpenBLAS_LIBNAME})
  39. if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
  40. string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
  41. target_link_libraries(x${float_char}cblat1 omp pthread)
  42. endif()
  43. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  44. target_link_libraries(x${float_char}cblat1 m)
  45. endif()
  46. add_test(NAME "x${float_char}cblat1"
  47. COMMAND $<TARGET_FILE:x${float_char}cblat1>)
  48. #level2
  49. if (NOT NOFORTRAN)
  50. add_executable(x${float_char}cblat2
  51. c_${float_char}blat2.f
  52. c_${float_char}blas2.c
  53. c_${float_char}2chke.c
  54. auxiliary.c
  55. c_xerbla.c
  56. constant.c)
  57. else()
  58. add_executable(x${float_char}cblat2
  59. c_${float_char}blat2c.c
  60. c_${float_char}blas2.c
  61. c_${float_char}2chke.c
  62. auxiliary.c
  63. c_xerbla.c
  64. constant.c)
  65. endif()
  66. target_link_libraries(x${float_char}cblat2 ${OpenBLAS_LIBNAME})
  67. if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
  68. string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
  69. target_link_libraries(x${float_char}cblat2 omp pthread)
  70. endif()
  71. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  72. target_link_libraries(x${float_char}cblat2 m)
  73. endif()
  74. add_test(NAME "x${float_char}cblat2"
  75. COMMAND ${test_helper} $<TARGET_FILE:x${float_char}cblat2> "${PROJECT_SOURCE_DIR}/ctest/${float_char}in2")
  76. #level3
  77. if (NOT NOFORTRAN)
  78. add_executable(x${float_char}cblat3
  79. c_${float_char}blat3.f
  80. c_${float_char}blas3.c
  81. c_${float_char}3chke.c
  82. auxiliary.c
  83. c_xerbla.c
  84. constant.c)
  85. else()
  86. add_executable(x${float_char}cblat3
  87. c_${float_char}blat3c.c
  88. c_${float_char}blas3.c
  89. c_${float_char}3chke.c
  90. auxiliary.c
  91. c_xerbla.c
  92. constant.c)
  93. endif()
  94. target_link_libraries(x${float_char}cblat3 ${OpenBLAS_LIBNAME})
  95. if (USE_OPENMP AND (${CMAKE_Fortran_COMPILER_ID} STREQUAL GNU) AND (${CMAKE_C_COMPILER_ID} STREQUAL Clang))
  96. string(REGEX REPLACE "-fopenmp" "" CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}")
  97. target_link_libraries(x${float_char}cblat3 omp pthread)
  98. endif()
  99. if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "QNX")
  100. target_link_libraries(x${float_char}cblat3 m)
  101. endif()
  102. add_test(NAME "x${float_char}cblat3"
  103. COMMAND ${test_helper} $<TARGET_FILE:x${float_char}cblat3> "${PROJECT_SOURCE_DIR}/ctest/${float_char}in3")
  104. endforeach()