CMakeLists.txt 1.0 KB

12345678910111213141516171819202122232425
  1. # 获取当前目录下的所有目录
  2. file(GLOB directories RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*)
  3. foreach(dir ${directories})
  4. if (DEFINED ENABLE_PROJECT)
  5. list(FIND ENABLE_PROJECT ${dir} PROJECT)
  6. if(NOT PROJECT EQUAL -1)
  7. if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  8. if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt")
  9. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  10. else ()
  11. message("Can't find dir: " "${CMAKE_SOURCE_DIR}/${dir}/CMakeLists.txt")
  12. endif ()
  13. endif ()
  14. endif()
  15. else()
  16. if(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  17. if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${dir}/CMakeLists.txt")
  18. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${dir})
  19. else ()
  20. message("Can't find dir: " "${CMAKE_SOURCE_DIR}/${dir}/CMakeLists.txt")
  21. endif ()
  22. endif ()
  23. endif ()
  24. endforeach()