diff options
Diffstat (limited to 'Tests/RunCMake/VS10Project')
15 files changed, 168 insertions, 27 deletions
diff --git a/Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp b/Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp new file mode 100644 index 0000000..3695dc9 --- /dev/null +++ b/Tests/RunCMake/VS10Project/Dir/DirNested/foo_nested.cpp @@ -0,0 +1,3 @@ +void foo() +{ +} diff --git a/Tests/RunCMake/VS10Project/Dir/foo.cpp b/Tests/RunCMake/VS10Project/Dir/foo.cpp new file mode 100644 index 0000000..3695dc9 --- /dev/null +++ b/Tests/RunCMake/VS10Project/Dir/foo.cpp @@ -0,0 +1,3 @@ +void foo() +{ +} diff --git a/Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp b/Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp new file mode 100644 index 0000000..3695dc9 --- /dev/null +++ b/Tests/RunCMake/VS10Project/Prefixed/PrefixedNested/bar_nested.cpp @@ -0,0 +1,3 @@ +void foo() +{ +} diff --git a/Tests/RunCMake/VS10Project/Prefixed/bar.cpp b/Tests/RunCMake/VS10Project/Prefixed/bar.cpp new file mode 100644 index 0000000..b72a1a5 --- /dev/null +++ b/Tests/RunCMake/VS10Project/Prefixed/bar.cpp @@ -0,0 +1,3 @@ +void bar() +{ +} diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 27b81b7..5ca069a 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -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) @@ -22,6 +23,8 @@ run_cmake(VsSdkDirectories) run_cmake(VsGlobals) run_cmake(VsProjectImport) run_cmake(VsPackageReferences) +run_cmake(VsDpiAware) +run_cmake(VsDpiAwareBadParam) if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05) run_cmake(VsJustMyCode) diff --git a/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake index c2a94bb..616f38b 100644 --- a/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake +++ b/Tests/RunCMake/VS10Project/SourceGroupCMakeLists-check.cmake @@ -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) diff --git a/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake b/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake new file mode 100644 index 0000000..c82a66e --- /dev/null +++ b/Tests/RunCMake/VS10Project/SourceGroupHelpers.cmake @@ -0,0 +1,35 @@ +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() diff --git a/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake new file mode 100644 index 0000000..655120a --- /dev/null +++ b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists-check.cmake @@ -0,0 +1,25 @@ +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() diff --git a/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake new file mode 100644 index 0000000..83c87a9 --- /dev/null +++ b/Tests/RunCMake/VS10Project/SourceGroupTreeCMakeLists.cmake @@ -0,0 +1,16 @@ +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}) diff --git a/Tests/RunCMake/VS10Project/VsDpiAware-check.cmake b/Tests/RunCMake/VS10Project/VsDpiAware-check.cmake new file mode 100644 index 0000000..fbb64f0 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDpiAware-check.cmake @@ -0,0 +1,41 @@ +macro(VSDpiAware_check tgt dpiaware_match_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_DPIAWARE_MATCH 0) + set(IN_MANIFEST_SETTINGS 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<Manifest>") + set(IN_MANIFEST_SETTINGS 1) + elseif(line MATCHES "^ *</Manifest>") + set(IN_MANIFEST_SETTINGS 0) + elseif(IN_MANIFEST_SETTINGS AND (line MATCHES "^ *<EnableDpiAwareness>([^<>]+)</EnableDpiAwareness>")) + set(dpiaware_match_actual "${CMAKE_MATCH_1}") + if(NOT "${dpiaware_match_actual}" STREQUAL "${dpiaware_match_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <EnableDpiAwareness> '${dpiaware_match_actual}', not '${dpiaware_match_expect}'.") + return() + endif() + set(HAVE_DPIAWARE_MATCH 1) + break() + endif() + endforeach() + + if(NOT HAVE_DPIAWARE_MATCH AND NOT "${dpiaware_match_expect}" STREQUAL "") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <EnableDpiAwareness> property group.") + return() + endif() +endmacro() + +VSDpiAware_check(DPIAWARE-default-C "") +VSDpiAware_check(DPIAWARE-default-CXX "") +VSDpiAware_check(DPIAWARE-TGT-PERMONITOR-C "PerMonitorHighDPIAware") +VSDpiAware_check(DPIAWARE-TGT-PERMONITOR-CXX "PerMonitorHighDPIAware") +VSDpiAware_check(DPIAWARE-TGT-ON-C "true") +VSDpiAware_check(DPIAWARE-TGT-ON-CXX "true") +VSDpiAware_check(DPIAWARE-TGT-OFF-C "false") +VSDpiAware_check(DPIAWARE-TGT-OFF-CXX "false") diff --git a/Tests/RunCMake/VS10Project/VsDpiAware.cmake b/Tests/RunCMake/VS10Project/VsDpiAware.cmake new file mode 100644 index 0000000..74e3d21 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDpiAware.cmake @@ -0,0 +1,19 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(C) +enable_language(CXX) + +add_executable(DPIAWARE-default-C empty.c) +add_executable(DPIAWARE-default-CXX empty.cxx) + +add_executable(DPIAWARE-TGT-PERMONITOR-C empty.c) +set_property(TARGET DPIAWARE-TGT-PERMONITOR-C PROPERTY VS_DPI_AWARE "PerMonitor") +add_executable(DPIAWARE-TGT-PERMONITOR-CXX empty.cxx) +set_property(TARGET DPIAWARE-TGT-PERMONITOR-CXX PROPERTY VS_DPI_AWARE "PerMonitor") +add_executable(DPIAWARE-TGT-ON-C empty.c) +set_property(TARGET DPIAWARE-TGT-ON-C PROPERTY VS_DPI_AWARE ON) +add_executable(DPIAWARE-TGT-ON-CXX empty.cxx) +set_property(TARGET DPIAWARE-TGT-ON-CXX PROPERTY VS_DPI_AWARE ON) +add_executable(DPIAWARE-TGT-OFF-C empty.c) +set_property(TARGET DPIAWARE-TGT-OFF-C PROPERTY VS_DPI_AWARE OFF) +add_executable(DPIAWARE-TGT-OFF-CXX empty.cxx) +set_property(TARGET DPIAWARE-TGT-OFF-CXX PROPERTY VS_DPI_AWARE OFF) diff --git a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt new file mode 100644 index 0000000..95fc5ca --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam-stderr.txt @@ -0,0 +1,3 @@ +CMake Error: Bad parameter for VS_DPI_AWARE: Bar +CMake Error: Bad parameter for VS_DPI_AWARE: Foo +CMake Generate step failed. Build files cannot be regenerated correctly. diff --git a/Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake new file mode 100644 index 0000000..e05452b --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsDpiAwareBadParam.cmake @@ -0,0 +1,8 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +enable_language(C) +enable_language(CXX) + +add_executable(DPIAWARE-TGT-BADPARAM-C empty.c) +set_property(TARGET DPIAWARE-TGT-BADPARAM-C PROPERTY VS_DPI_AWARE "Foo") +add_executable(DPIAWARE-TGT-BADPARAM-CXX empty.cxx) +set_property(TARGET DPIAWARE-TGT-BADPARAM-CXX PROPERTY VS_DPI_AWARE "Bar") diff --git a/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake index 4ff5327..512a1c9 100644 --- a/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake +++ b/Tests/RunCMake/VS10Project/VsPackageReferences-check.cmake @@ -25,7 +25,7 @@ foreach(i 1 2) if(line MATCHES "^ *<PackageReference .* Version=\"${testVersion}\".*>$") set(Library${i}Found TRUE) message(STATUS "foo.vcxproj is using package reference ${testLibrary} with version ${testVersion}") - elseif() + else() message(STATUS "foo.vcxproj failed to define reference ${testLibrary} with version ${testVersion}") set(Library${i}Found FALSE) endif() |