ArchIndependent.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Hard-code architecture for test without a real compiler.
  2. set(CMAKE_SIZEOF_VOID_P 4)
  3. include(WriteBasicConfigVersionFile)
  4. set(_dummy_version 1.0.0)
  5. set(_compatibilities AnyNewerVersion
  6. SameMajorVersion
  7. SameMinorVersion
  8. ExactVersion)
  9. function(test_write_basic_config_version_file_arch_prepare filename_out compat arch_independent arch)
  10. if(arch_independent)
  11. set(arch_arg ARCH_INDEPENDENT)
  12. else()
  13. set(arch_arg )
  14. endif()
  15. set(filename "${CMAKE_CURRENT_BINARY_DIR}/${compat}Arch${arch_arg}ConfigVersion.cmake")
  16. set(CMAKE_SIZEOF_VOID_P "${arch}")
  17. write_basic_config_version_file("${filename}"
  18. VERSION "${_dummy_version}"
  19. COMPATIBILITY "${compat}"
  20. ${arch_arg})
  21. set("${filename_out}" "${filename}" PARENT_SCOPE)
  22. endfunction()
  23. function(test_write_basic_config_version_file_arch_check unsuitable_out filename arch)
  24. set(CMAKE_SIZEOF_VOID_P "${arch}")
  25. set(PACKAGE_FIND_VERSION "${_dummy_version}")
  26. include("${filename}")
  27. set("${unsuitable_out}" "${PACKAGE_VERSION_UNSUITABLE}" PARENT_SCOPE)
  28. endfunction()
  29. function(test_write_basic_config_version_file_arch_test expected_unsuitable compat arch_independent source_arch user_arch)
  30. test_write_basic_config_version_file_arch_prepare(filename "${compat}" "${arch_independent}" "${source_arch}")
  31. test_write_basic_config_version_file_arch_check(unsuitable "${filename}" "${user_arch}")
  32. if(unsuitable AND NOT expected_unsuitable)
  33. message(SEND_ERROR "Architecture was checked when it shouldn't have been. Compatibility: ${compat} ARCH_INDEPENDENT: ${arch_independent}.")
  34. elseif(expected_unsuitable AND NOT unsuitable)
  35. message(SEND_ERROR "Requested architecture check not performed. Compatibility: ${compat} ARCH_INDEPENDENT: ${arch_independent}.")
  36. endif()
  37. endfunction()
  38. set(_unsuitable TRUE)
  39. set(_suitable FALSE)
  40. foreach(compat ${_compatibilities})
  41. test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 4 4)
  42. test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" FALSE 4 4)
  43. test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 4 8)
  44. test_write_basic_config_version_file_arch_test("${_unsuitable}" "${compat}" FALSE 4 8)
  45. test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 8 4)
  46. test_write_basic_config_version_file_arch_test("${_unsuitable}" "${compat}" FALSE 8 4)
  47. test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" TRUE 8 8)
  48. test_write_basic_config_version_file_arch_test("${_suitable}" "${compat}" FALSE 8 8)
  49. endforeach()