CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cmake_minimum_required (VERSION 3.8)
  2. project(SourceGroups)
  3. # this is not really a test which can fail
  4. # it is more an example with several source_group()
  5. # commands.
  6. # The created projects have to be loaded manually
  7. # in Visual Studio/Xcode/Eclipse/...
  8. # to see whether the correct groups have been created.
  9. source_group(Base FILES main.c)
  10. # a sub group
  11. source_group(Base\\Sub1 FILES sub1/foo.c)
  12. # a sub sub group
  13. source_group(Base\\Sub1\\Sub2 FILES sub1/foobar.c)
  14. # a group with empty name
  15. source_group("" FILES foo.c)
  16. # a group, whose name consists only of the delimiter
  17. #should be handled the same way as an empty name
  18. source_group("\\" FILES baz.c)
  19. # a sub sub group whose last component has the same name
  20. # as an already existing group
  21. source_group(Base\\Sub1\\Base FILES bar.c)
  22. # a group without files, is currently not created
  23. source_group(EmptyGroup)
  24. set(root ${CMAKE_CURRENT_SOURCE_DIR})
  25. set(tree_files_without_prefix ${root}/sub1/tree_bar.c
  26. sub1/tree_baz.c
  27. sub1/../sub1/tree_subdir/tree_foobar.c)
  28. set(tree_files_with_prefix ${root}/tree_prefix_foo.c
  29. tree_prefix_bar.c)
  30. set(tree_files_with_empty_prefix ${root}/tree_empty_prefix_foo.c
  31. tree_empty_prefix_bar.c)
  32. source_group(TREE ${root} FILES ${tree_files_without_prefix})
  33. source_group(FILES ${tree_files_with_prefix} PREFIX tree_root/subgroup TREE ${root})
  34. source_group(PREFIX "" FILES ${tree_files_with_empty_prefix} TREE ${root})
  35. add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c
  36. ${tree_files_with_prefix} ${tree_files_without_prefix}
  37. ${tree_files_with_empty_prefix} README.txt)