FindCBLAS.cmake 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. ################################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2016 HPCC Systems®.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ################################################################################
  16. if(NOT CBLAS_FOUND)
  17. if(WIN32)
  18. set(cblas_lib "cblas")
  19. else()
  20. set(cblas_lib cblas tatlas satlas)
  21. endif()
  22. find_path(CBLAS_INCLUDE_DIR NAMES cblas.h)
  23. find_library(CBLAS_LIBRARIES NAMES ${cblas_lib} PATHS /usr/lib/atlas /usr/lib64/atlas)
  24. include(FindPackageHandleStandardArgs)
  25. find_package_handle_standard_args(CBLAS
  26. DEFAULT_MSG
  27. CBLAS_LIBRARIES
  28. CBLAS_INCLUDE_DIR)
  29. if (APPLE AND ${CMAKE_SYSTEM_VERSION} VERSION_LESS "18.2.0") # 18.2.0 is macOS Mojave (10.14)
  30. set(LIB_TO_DO ${CBLAS_LIBRARIES})
  31. set(CBLAS_DEPS_LIBS "")
  32. foreach (lib libquadmath;libgfortran;libgcc_s)
  33. message("otool -L ${LIB_TO_DO} | egrep ${lib}(.[0-9]{1,})*.dylib | sed \"s/^[[:space:]]//g\" | cut -d' ' -f1")
  34. execute_process(
  35. COMMAND bash "-c" "otool -L \"${LIB_TO_DO}\" | egrep \"${lib}(.[0-9]{1,})*.dylib\" | sed \"s/^[[:space:]]//g\" | cut -d' ' -f1"
  36. OUTPUT_VARIABLE otoolOut
  37. ERROR_VARIABLE otoolErr
  38. OUTPUT_STRIP_TRAILING_WHITESPACE
  39. )
  40. if (NOT "${otoolErr}" STREQUAL "")
  41. message(FATAL_ERROR "Failed to check dependent lib ${lib} for ${LIB_TO_DO}")
  42. endif()
  43. if ("${otoolOut}" STREQUAL "")
  44. message(FATAL_ERROR "${LIB_TO_DO} dependencies changed. Run otool -L check manually and update file FindCBLAS.cmake")
  45. endif()
  46. list(APPEND CBLAS_DEPS_LIBS ${otoolOut})
  47. if ("${otoolOut}" MATCHES ".*libgfortran.*")
  48. set(LIB_TO_DO "${otoolOut}")
  49. endif()
  50. endforeach()
  51. endif()
  52. mark_as_advanced(CBLAS_INCLUDE_DIR CBLAS_LIBRARIES)
  53. endif()