1
0

CMakeLists.txt 1.2 KB

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