KoXeN

CMake MSVC Folders Struct

Apr 22nd, 2019 (edited)
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. # Create virtual folders to make it look nicer in VS
  2. if(MSVC_IDE)
  3. # Macro to preserve source files hierarchy in the IDE
  4. macro(GroupSources curdir)
  5. file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
  6.  
  7. foreach(child ${children})
  8. if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
  9. GroupSources(${curdir}/${child})
  10. else()
  11. string(REPLACE "/" "\\" groupname ${curdir})
  12. string(REPLACE "src" "Sources" groupname ${groupname})
  13. source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
  14. endif()
  15. endforeach()
  16. endmacro()
  17.  
  18. # Run macro
  19. GroupSources(src)
  20. endif()
Add Comment
Please, Sign In to add comment