InheritedParameters-check.cmake 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/InheritedParameters.xcodeproj/project.pbxproj")
  2. if(NOT EXISTS "${xcProjectFile}")
  3. set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.")
  4. return()
  5. endif()
  6. set(found_inherited_GCC_PREPROCESSOR_DEFINITIONS 1)
  7. set(found_inherited_OTHER_CFLAGS 1)
  8. set(found_inherited_OTHER_LDFLAGS 1)
  9. set(found_inherited_OTHER_SWIFT_FLAGS 1)
  10. set(found_inherited_SWIFT_ACTIVE_COMPILATION_CONDITIONS 1)
  11. file(STRINGS "${xcProjectFile}" lines)
  12. foreach(line IN LISTS lines)
  13. if(line MATCHES [[GCC_PREPROCESSOR_DEFINITIONS]])
  14. if(NOT line MATCHES [["\$\(inherited\)"]])
  15. string(APPEND relevant_lines " ${line}\n")
  16. set(found_inherited_GCC_PREPROCESSOR_DEFINITIONS 0)
  17. endif()
  18. endif()
  19. if(line MATCHES [[OTHER_CFLAGS]])
  20. if(NOT line MATCHES [["\$\(inherited\)"]])
  21. string(APPEND relevant_lines " ${line}\n")
  22. set(found_inherited_OTHER_CFLAGS 0)
  23. endif()
  24. endif()
  25. if(line MATCHES [[OTHER_LDFLAGS]])
  26. if(NOT line MATCHES [["\$\(inherited\)"]])
  27. string(APPEND relevant_lines " ${line}\n")
  28. set(found_inherited_OTHER_LDFLAGS 0)
  29. endif()
  30. endif()
  31. if(line MATCHES [[OTHER_SWIFT_FLAGS]])
  32. if(NOT line MATCHES [["\$\(inherited\)"]])
  33. string(APPEND relevant_lines " ${line}\n")
  34. set(found_inherited_OTHER_SWIFT_FLAGS 0)
  35. endif()
  36. endif()
  37. if(line MATCHES [[SWIFT_ACTIVE_COMPILATION_CONDITIONS]])
  38. if(NOT line MATCHES [["\$\(inherited\)"]])
  39. string(APPEND relevant_lines " ${line}\n")
  40. set(found_inherited_SWIFT_ACTIVE_COMPILATION_CONDITIONS 0)
  41. endif()
  42. endif()
  43. endforeach()
  44. if(NOT found_inherited_GCC_PREPROCESSOR_DEFINITIONS)
  45. string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for GCC_PREPROCESSOR_DEFINITIONS in\n ${xcProjectFile}\n")
  46. endif()
  47. if(NOT found_inherited_OTHER_CFLAGS)
  48. string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for OTHER_CFLAGS in\n ${xcProjectFile}\n")
  49. endif()
  50. if(NOT found_inherited_OTHER_LDFLAGS)
  51. string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for OTHER_LDFLAGS in\n ${xcProjectFile}\n")
  52. endif()
  53. if(CMake_TEST_Swift)
  54. if(NOT found_inherited_OTHER_SWIFT_FLAGS)
  55. string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for OTHER_SWIFT_FLAGS in\n ${xcProjectFile}\n")
  56. endif()
  57. if(NOT found_inherited_SWIFT_ACTIVE_COMPILATION_CONDITIONS)
  58. string(APPEND RunCMake_TEST_FAILED "Found missing inherited value for SWIFT_ACTIVE_COMPILATION_CONDITIONS in\n ${xcProjectFile}\n")
  59. endif()
  60. endif()
  61. if(RunCMake_TEST_FAILED)
  62. string(APPEND RunCMake_TEST_FAILED "Relevant lines include\n${relevant_lines}")
  63. endif()