summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake
blob: 7655e60944e39316ff86f1810226b5026ae05f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
set(CMAKE_CONFIGURATION_TYPES Debug)

# Test regular tree grouping.
set(SRC_FILES
  ${CMAKE_CURRENT_SOURCE_DIR}/Dir/foo.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Dir/DirNested/foo_nested.cpp
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC_FILES})


# Test files that are not present at configuration time.
set(GENERATED_SRC_FILES
  ${CMAKE_CURRENT_BINARY_DIR}/Generated/generated.cpp
)

file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Generated)

if(WIN32)
  add_custom_command(OUTPUT ${GENERATED_SRC_FILES}
    COMMAND echo. 2>${CMAKE_CURRENT_BINARY_DIR}\\Generated\\generated.cpp
  )
else()
  add_custom_command(OUTPUT ${GENERATED_SRC_FILES}
    COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/Generated/generated.cpp
  )
endif()

source_group(TREE ${CMAKE_CURRENT_BINARY_DIR} FILES ${GENERATED_SRC_FILES})


# Test prefixed tree grouping.
set(PREFIXED_SRC_FILES
  ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed/bar.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed/PrefixedNested/bar_nested.cpp
)

add_custom_target(SourceGroupTree
  SOURCES
    ${SRC_FILES}
    ${GENERATED_SRC_FILES}
    ${PREFIXED_SRC_FILES}
)

source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed PREFIX SourcesPrefix FILES ${PREFIXED_SRC_FILES})