RunCMakeTest.cmake 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. include(RunCMake)
  2. # Build a framework that the other tests will use and treat as external.
  3. # Always build in the Debug configuration so that the path to the framework
  4. # is predictable.
  5. function(ExternalFramework)
  6. set(RunCMake_TEST_NO_CLEAN 1)
  7. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExternalFramework-build)
  8. set(externalFramework ${RunCMake_TEST_BINARY_DIR}/Debug/sharedFrameworkExt.framework PARENT_SCOPE)
  9. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  10. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  11. run_cmake(ExternalFramework)
  12. run_cmake_command(ExternalFramework-build
  13. ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}
  14. --config Debug
  15. --target sharedFrameworkExt
  16. )
  17. endfunction()
  18. ExternalFramework()
  19. set(RunCMake_TEST_OPTIONS -DEXTERNAL_FWK=${externalFramework})
  20. run_cmake(EmbedFrameworksFlagsOff)
  21. function(TestFlagsOn testName)
  22. set(RunCMake_TEST_NO_CLEAN 1)
  23. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
  24. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  25. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  26. run_cmake(${testName})
  27. run_cmake_command(${testName}-build
  28. ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}
  29. --config Debug
  30. --target app
  31. )
  32. endfunction()
  33. TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir)
  34. TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir)
  35. function(TestAppExtension platform)
  36. set(testName EmbedAppExtensions-${platform})
  37. if(NOT platform STREQUAL "macOS")
  38. set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=${platform})
  39. endif()
  40. set(RunCMake_TEST_NO_CLEAN 1)
  41. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
  42. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  43. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  44. run_cmake(${testName})
  45. run_cmake_command(${testName}-build
  46. ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}
  47. --config Debug
  48. --target app
  49. )
  50. endfunction()
  51. # Isolate device tests from host architecture selection.
  52. unset(ENV{CMAKE_OSX_ARCHITECTURES})
  53. if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
  54. # The various flag on/off combinations are tested by the EmbedFrameworks...
  55. # tests, so we don't duplicate all the combinations here. We only verify the
  56. # defaults, which is to remove headers on copy, but not code sign.
  57. TestAppExtension(macOS)
  58. TestAppExtension(iOS)
  59. endif()