RunCMakeTest.cmake 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. include(RunCMake)
  2. # Build dependencies 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(ExternalDependencies)
  6. set(RunCMake_TEST_NO_CLEAN 1)
  7. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ExternalDependencies-build)
  8. set(externalFramework ${RunCMake_TEST_BINARY_DIR}/Debug/sharedFrameworkExt.framework PARENT_SCOPE)
  9. set(externalDylib ${RunCMake_TEST_BINARY_DIR}/Debug/libsharedDylibExt.dylib PARENT_SCOPE)
  10. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  11. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  12. run_cmake(ExternalDependencies)
  13. run_cmake_command(ExternalDependencies-build
  14. ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}
  15. --config Debug
  16. --target sharedFrameworkExt sharedDylibExt
  17. )
  18. endfunction()
  19. ExternalDependencies()
  20. function(TestFlagsOn testName dependencyName)
  21. set(RunCMake_TEST_NO_CLEAN 1)
  22. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-${dependencyName}-build)
  23. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  24. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  25. run_cmake(${testName})
  26. run_cmake_command(${testName}-${dependencyName}-build
  27. ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}
  28. --config Debug
  29. --target app
  30. )
  31. endfunction()
  32. foreach(dependency ${externalFramework} ${externalDylib})
  33. cmake_path(GET dependency FILENAME dependencyName)
  34. set(RunCMake_TEST_OPTIONS -DEXTERNAL_DEPENDENCY=${dependency} -DEXTERNAL_DEPENDENCY_NAME=${dependencyName})
  35. run_cmake(EmbedFrameworksFlagsOff)
  36. TestFlagsOn(EmbedFrameworksFlagsOnNoSubdir ${dependencyName})
  37. TestFlagsOn(EmbedFrameworksFlagsOnWithSubdir ${dependencyName})
  38. endforeach()
  39. unset(RunCMake_TEST_OPTIONS)
  40. function(TestAppExtension platform)
  41. set(testName EmbedAppExtensions-${platform})
  42. if(NOT platform STREQUAL "macOS")
  43. set(RunCMake_TEST_OPTIONS -DCMAKE_SYSTEM_NAME=${platform})
  44. endif()
  45. set(RunCMake_TEST_NO_CLEAN 1)
  46. set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${testName}-build)
  47. file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
  48. file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
  49. run_cmake(${testName})
  50. run_cmake_command(${testName}-build
  51. ${CMAKE_COMMAND} --build ${RunCMake_TEST_BINARY_DIR}
  52. --config Debug
  53. --target app
  54. )
  55. endfunction()
  56. # Isolate device tests from host architecture selection.
  57. unset(ENV{CMAKE_OSX_ARCHITECTURES})
  58. if(XCODE_VERSION VERSION_GREATER_EQUAL 8)
  59. # The various flag on/off combinations are tested by the EmbedFrameworks...
  60. # tests, so we don't duplicate all the combinations here. We only verify the
  61. # defaults, which is to remove headers on copy, but not code sign.
  62. TestAppExtension(macOS)
  63. TestAppExtension(iOS)
  64. endif()