check_object_files.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. if (NOT EXISTS ${OBJLIB_LISTFILE})
  2. message(SEND_ERROR "Object listing file \"${OBJLIB_LISTFILE}\" not found!")
  3. endif()
  4. file(STRINGS ${OBJLIB_LISTFILE} objlib_files)
  5. list(LENGTH objlib_files num_objectfiles)
  6. if (NOT EXPECTED_NUM_OBJECTFILES EQUAL num_objectfiles)
  7. message(SEND_ERROR "Unexpected number of entries in object list file (${num_objectfiles} instead of ${EXPECTED_NUM_OBJECTFILES})")
  8. endif()
  9. foreach(objlib_file ${objlib_files})
  10. set(file_exists False)
  11. if (EXISTS ${objlib_file})
  12. set(file_exists True)
  13. endif()
  14. if (NOT file_exists)
  15. if (objlib_file MATCHES ".(CURRENT_ARCH)")
  16. string(REPLACE "$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)" "*" config_file "${objlib_file}")
  17. string(REPLACE "$(PROJECT_NAME)" "GeneratorExpression" config_file "${config_file}")
  18. string(REPLACE "$(CURRENT_ARCH)" "*" config_file "${config_file}")
  19. file(GLOB_RECURSE files "${config_file}")
  20. list(LENGTH files num_files)
  21. if (NOT files)
  22. message(SEND_ERROR "Got no files for expression ${config_file}")
  23. endif()
  24. set(file_exists True)
  25. else()
  26. foreach(config_macro "$(Configuration)" "$(OutDir)" "$(IntDir)")
  27. string(REPLACE "${config_macro}" "${TEST_CONFIGURATION}" config_file "${objlib_file}")
  28. list(APPEND attempts ${config_file})
  29. if (EXISTS ${config_file})
  30. set(file_exists True)
  31. endif()
  32. endforeach()
  33. endif()
  34. endif()
  35. if (NOT file_exists)
  36. if(attempts)
  37. list(REMOVE_DUPLICATES attempts)
  38. set(tried " Tried ${attempts}")
  39. endif()
  40. message(SEND_ERROR "File \"${objlib_file}\" does not exist!${tried}")
  41. endif()
  42. endforeach()