MakeAvailable.cmake 844 B

1234567891011121314151617181920212223242526272829
  1. include(FetchContent)
  2. FetchContent_Declare(
  3. WithProject
  4. SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithProject
  5. )
  6. FetchContent_Declare(
  7. WithoutProject
  8. SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject
  9. )
  10. FetchContent_Declare(
  11. ProjectSubdir
  12. SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/WithoutProject
  13. SOURCE_SUBDIR ProjectSubdir
  14. )
  15. # Order is important and will be verified by test output
  16. FetchContent_MakeAvailable(WithProject WithoutProject ProjectSubdir)
  17. get_property(addedWith GLOBAL PROPERTY FetchWithProject SET)
  18. if(NOT addedWith)
  19. message(SEND_ERROR "Project with top level CMakeLists.txt not added")
  20. endif()
  21. get_property(addedSubdir GLOBAL PROPERTY FetchWithSubProject SET)
  22. if(NOT addedSubdir)
  23. message(SEND_ERROR "Project with CMakeLists.txt in subdir not added")
  24. endif()
  25. include(${withoutproject_SOURCE_DIR}/confirmMessage.cmake)