CMakeLists.txt 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. project(SourceGroups)
  2. # We need ansi C support, otherwise it doesn't build e.g. on HP-UX:
  3. # main.c", line 3: error 1705: Function prototypes are an ANSI feature.
  4. IF(CMAKE_ANSI_CFLAGS)
  5. SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
  6. ENDIF(CMAKE_ANSI_CFLAGS)
  7. # this is not really a test which can fail
  8. # it is more an example with several source_group()
  9. # commands.
  10. # The created projects have to be loaded manually
  11. # in Visual Studio/XCode/Eclipse/...
  12. # to see whether the correct groups have been created.
  13. source_group(Base FILES main.c)
  14. # a sub group
  15. source_group(Base\\Sub1 FILES sub1/foo.c)
  16. # a sub sub group
  17. source_group(Base\\Sub1\\Sub2 FILES sub1/foobar.c)
  18. # a group with empty name
  19. source_group("" FILES foo.c)
  20. # a group, whose name consists only of the delimiter
  21. #should be handled the same way as an empty name
  22. source_group("\\" FILES baz.c)
  23. # a sub sub group whose last component has the same name
  24. # as an already existing group
  25. source_group(Base\\Sub1\\Base FILES bar.c)
  26. # a group without files, is currently not created
  27. source_group(EmptyGroup)
  28. add_executable(SourceGroups main.c bar.c foo.c sub1/foo.c sub1/foobar.c baz.c)