CMakeLists.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. cmake_minimum_required (VERSION 2.8)
  2. project(MacRuntimePath)
  3. if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
  4. set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
  5. endif()
  6. # Wipe out the install tree to make sure the exporter works.
  7. add_custom_command(
  8. OUTPUT ${MacRuntimePath_BINARY_DIR}/CleanupProject
  9. COMMAND ${CMAKE_COMMAND} -E remove_directory ${MacRuntimePath_BINARY_DIR}/Root
  10. )
  11. add_custom_target(CleanupTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/CleanupProject)
  12. set_property(
  13. SOURCE ${MacRuntimePath_BINARY_DIR}/CleanupProject
  14. PROPERTY SYMBOLIC 1
  15. )
  16. configure_file(${MacRuntimePath_SOURCE_DIR}/InitialCache.cmake.in
  17. ${MacRuntimePath_BINARY_DIR}/InitialCache.cmake @ONLY)
  18. if(CMAKE_CONFIGURATION_TYPES)
  19. set(NESTED_CONFIG_TYPE -C "${CMAKE_CFG_INTDIR}")
  20. else()
  21. if(CMAKE_BUILD_TYPE)
  22. set(NESTED_CONFIG_TYPE -C "${CMAKE_BUILD_TYPE}")
  23. else()
  24. set(NESTED_CONFIG_TYPE)
  25. endif()
  26. endif()
  27. # Build and install the exporter.
  28. add_custom_command(
  29. OUTPUT ${MacRuntimePath_BINARY_DIR}/ExportProject
  30. COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE}
  31. --build-and-test
  32. ${MacRuntimePath_SOURCE_DIR}/A
  33. ${MacRuntimePath_BINARY_DIR}/A
  34. --build-noclean
  35. --build-project MacRuntimePath_A
  36. --build-target install
  37. --build-generator ${CMAKE_GENERATOR}
  38. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  39. --build-options -C${MacRuntimePath_BINARY_DIR}/InitialCache.cmake
  40. VERBATIM
  41. )
  42. add_custom_target(ExportTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/ExportProject)
  43. add_dependencies(ExportTarget CleanupTarget)
  44. set_property(
  45. SOURCE ${MacRuntimePath_BINARY_DIR}/ExportProject
  46. PROPERTY SYMBOLIC 1
  47. )
  48. # Build the importer.
  49. add_custom_command(
  50. OUTPUT ${MacRuntimePath_BINARY_DIR}/ImportProject
  51. COMMAND ${CMAKE_CTEST_COMMAND} ${NESTED_CONFIG_TYPE}
  52. --build-and-test
  53. ${MacRuntimePath_SOURCE_DIR}/B
  54. ${MacRuntimePath_BINARY_DIR}/B
  55. --build-noclean
  56. --build-project MacRuntimePath_B
  57. --build-generator ${CMAKE_GENERATOR}
  58. --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
  59. --build-options -C${MacRuntimePath_BINARY_DIR}/InitialCache.cmake
  60. VERBATIM
  61. )
  62. add_custom_target(ImportTarget ALL DEPENDS ${MacRuntimePath_BINARY_DIR}/ImportProject)
  63. add_dependencies(ImportTarget ExportTarget)
  64. set_property(
  65. SOURCE ${MacRuntimePath_BINARY_DIR}/ImportProject
  66. PROPERTY SYMBOLIC 1
  67. )