Commit 28ef1081 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'source_group-tests'

bb6e95ca source_group: Improved generated filters tests
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !3675
parents b6412b38 bb6e95ca
......@@ -5,6 +5,7 @@ run_cmake(VsCSharpCompilerOpts)
run_cmake(ExplicitCMakeLists)
run_cmake(RuntimeLibrary)
run_cmake(SourceGroupCMakeLists)
run_cmake(SourceGroupTreeCMakeLists)
run_cmake(VsConfigurationType)
run_cmake(VsTargetsFileReferences)
......
......@@ -4,30 +4,8 @@ if(NOT EXISTS "${vcFiltersFile}")
return()
endif()
set(foundFileFilter 0)
set(foundFilter 0)
file(STRINGS "${vcFiltersFile}" lines)
foreach(line IN LISTS lines)
if(line MATCHES "<Filter>CMakeListsSourceGroup</Filter>")
set(rule "${CMAKE_MATCH_1}")
if(foundFileFilter)
set(RunCMake_TEST_FAILED "Multiple files listed with filter for CMakeListsSourceGroup.")
return()
endif()
set(foundFileFilter 1)
endif()
if(line MATCHES "<Filter.*Include=\"CMakeListsSourceGroup\"")
set(rule "${CMAKE_MATCH_1}")
if(foundFilter)
set(RunCMake_TEST_FAILED "Multiple copies of CMakeListsSourceGroup filter listed.")
return()
endif()
set(foundFilter 1)
endif()
endforeach()
if(NOT foundFileFilter)
set(RunCMake_TEST_FAILED "File filter for CMakeListsSourceGroup not found.")
endif()
if(NOT foundFilter)
set(RunCMake_TEST_FAILED "Filter CMakeListsSourceGroup not found.")
endif()
include(${RunCMake_TEST_SOURCE_DIR}/SourceGroupHelpers.cmake)
find_source_group("${lines}" CMakeListsSourceGroup)
function(find_source_group LINES NAME)
set(foundFileFilter 0)
set(foundFilter 0)
foreach(line IN LISTS LINES)
if(line MATCHES "<Filter>${NAME}</Filter>")
if(foundFileFilter)
set(RunCMake_TEST_FAILED "Multiple files listed with filter for ${NAME}." PARENT_SCOPE)
set(FILTER_FOUND 0 PARENT_SCOPE)
return()
endif()
set(foundFileFilter 1)
endif()
if(line MATCHES "<Filter.*Include=\"${NAME}\"")
if(foundFilter)
set(RunCMake_TEST_FAILED "Multiple copies of ${NAME} filter listed." PARENT_SCOPE)
set(FILTER_FOUND 0 PARENT_SCOPE)
return()
endif()
set(foundFilter 1)
endif()
endforeach()
if(NOT foundFileFilter)
set(RunCMake_TEST_FAILED "File filter for ${NAME} not found." PARENT_SCOPE)
set(FILTER_FOUND 0 PARENT_SCOPE)
return()
endif()
if(NOT foundFilter)
set(RunCMake_TEST_FAILED "Filter ${NAME} not found." PARENT_SCOPE)
set(FILTER_FOUND 0 PARENT_SCOPE)
return()
endif()
set(FILTER_FOUND 1 PARENT_SCOPE)
endfunction()
cmake_policy(SET CMP0011 NEW)
set(vcFiltersFile "${RunCMake_TEST_BINARY_DIR}/SourceGroupTree.vcxproj.filters")
if(NOT EXISTS "${vcFiltersFile}")
set(RunCMake_TEST_FAILED "Filters file ${vcFiltersFile} does not exist.")
return()
endif()
file(STRINGS "${vcFiltersFile}" lines)
include(${RunCMake_TEST_SOURCE_DIR}/SourceGroupHelpers.cmake)
set(SOURCE_GROUPS_TO_FIND
"Dir"
"Dir\\DirNested"
"SourcesPrefix"
"SourcesPrefix\\PrefixedNested"
)
foreach(GROUP_NAME IN LISTS ${SOURCE_GROUPS_TO_FIND})
find_source_group("${lines}" ${GROUP_NAME})
if(NOT ${FILTER_FOUND})
return()
endif()
endforeach()
set(CMAKE_CONFIGURATION_TYPES Debug)
set(SRC_FILES
${CMAKE_CURRENT_SOURCE_DIR}/Dir/foo.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Dir/DirNested/foo_nested.cpp
)
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} ${PREFIXED_SRC_FILES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR} FILES ${SRC_FILES})
source_group(TREE ${CMAKE_CURRENT_SOURCE_DIR}/Prefixed PREFIX SourcesPrefix FILES ${PREFIXED_SRC_FILES})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment