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.

f_check.cmake 1.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ##
  2. ## Author: Hank Anderson <hank@statease.com>
  3. ## Copyright: (c) Stat-Ease, Inc.
  4. ## Created: 12/29/14
  5. ## Last Modified: 12/29/14
  6. ## Description: Ported from the OpenBLAS/f_check perl script.
  7. ## This is triggered by prebuild.cmake and runs before any of the code is built.
  8. ## Appends Fortran information to config.h and Makefile.conf.
  9. # CMake vars set by this file:
  10. # F_COMPILER
  11. # FC
  12. # BU
  13. # NOFORTRAN
  14. # NEED2UNDERSCORES
  15. # FEXTRALIB
  16. # Defines set by this file:
  17. # BUNDERSCORE
  18. # NEEDBUNDERSCORE
  19. # NEED2UNDERSCORES
  20. if (MSVC)
  21. # had to do this for MSVC, else CMake automatically assumes I have ifort... -hpa
  22. include(CMakeForceCompiler)
  23. CMAKE_FORCE_Fortran_COMPILER(gfortran GNU)
  24. endif ()
  25. if (NOT NO_LAPACK)
  26. enable_language(Fortran)
  27. else()
  28. include(CMakeForceCompiler)
  29. CMAKE_FORCE_Fortran_COMPILER(gfortran GNU)
  30. endif()
  31. if (NOT ONLY_CBLAS)
  32. # N.B. f_check is not cross-platform, so instead try to use CMake variables
  33. # run f_check (appends to TARGET files)
  34. # message(STATUS "Running f_check...")
  35. # execute_process(COMMAND perl f_check ${TARGET_MAKE} ${TARGET_CONF} ${CMAKE_Fortran_COMPILER}
  36. # WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
  37. # TODO: detect whether underscore needed, set #defines and BU appropriately - use try_compile
  38. # TODO: set FEXTRALIB flags a la f_check?
  39. set(BU "_")
  40. file(APPEND ${TARGET_CONF}
  41. "#define BUNDERSCORE _\n"
  42. "#define NEEDBUNDERSCORE 1\n"
  43. "#define NEED2UNDERSCORES 0\n")
  44. else ()
  45. #When we only build CBLAS, we set NOFORTRAN=2
  46. set(NOFORTRAN 2)
  47. set(NO_FBLAS 1)
  48. #set(F_COMPILER GFORTRAN) # CMake handles the fortran compiler
  49. set(BU "_")
  50. file(APPEND ${TARGET_CONF}
  51. "#define BUNDERSCORE _\n"
  52. "#define NEEDBUNDERSCORE 1\n")
  53. endif()
  54. get_filename_component(F_COMPILER ${CMAKE_Fortran_COMPILER} NAME_WE)
  55. string(TOUPPER ${F_COMPILER} F_COMPILER)