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

64 lines
2.2 KiB

  1. # cmake/modules/language_support.cmake
  2. #
  3. # Temporary additional general language support is contained within this
  4. # file.
  5. # This additional function definition is needed to provide a workaround for
  6. # CMake bug 9220.
  7. # On debian testing (cmake 2.6.2), I get return code zero when calling
  8. # cmake the first time, but cmake crashes when running a second time
  9. # as follows:
  10. #
  11. # -- The Fortran compiler identification is unknown
  12. # CMake Error at /usr/share/cmake-2.6/Modules/CMakeFortranInformation.cmake:7 (GET_FILENAME_COMPONENT):
  13. # get_filename_component called with incorrect number of arguments
  14. # Call Stack (most recent call first):
  15. # CMakeLists.txt:3 (enable_language)
  16. #
  17. # My workaround is to invoke cmake twice. If both return codes are zero,
  18. # it is safe to invoke ENABLE_LANGUAGE(Fortran OPTIONAL)
  19. function(workaround_9220 language language_works)
  20. #message("DEBUG: language = ${language}")
  21. set(text
  22. "project(test NONE)
  23. cmake_minimum_required(VERSION 2.6.0)
  24. enable_language(${language} OPTIONAL)
  25. ")
  26. file(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/language_tests/${language})
  27. file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language})
  28. file(WRITE ${CMAKE_BINARY_DIR}/language_tests/${language}/CMakeLists.txt
  29. ${text})
  30. execute_process(
  31. COMMAND ${CMAKE_COMMAND} .
  32. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
  33. RESULT_VARIABLE return_code
  34. OUTPUT_QUIET
  35. ERROR_QUIET
  36. )
  37. if(return_code EQUAL 0)
  38. # Second run
  39. execute_process (
  40. COMMAND ${CMAKE_COMMAND} .
  41. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/language_tests/${language}
  42. RESULT_VARIABLE return_code
  43. OUTPUT_QUIET
  44. ERROR_QUIET
  45. )
  46. if(return_code EQUAL 0)
  47. set(${language_works} ON PARENT_SCOPE)
  48. else(return_code EQUAL 0)
  49. set(${language_works} OFF PARENT_SCOPE)
  50. endif(return_code EQUAL 0)
  51. else(return_code EQUAL 0)
  52. set(${language_works} OFF PARENT_SCOPE)
  53. endif(return_code EQUAL 0)
  54. endfunction(workaround_9220)
  55. # Temporary tests of the above function.
  56. #workaround_9220(CXX CXX_language_works)
  57. #message("CXX_language_works = ${CXX_language_works}")
  58. #workaround_9220(CXXp CXXp_language_works)
  59. #message("CXXp_language_works = ${CXXp_language_works}")