diff options
author | Brad King <brad.king@kitware.com> | 2016-03-24 12:49:41 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-03-24 12:49:41 (GMT) |
commit | 5b2acf6c1c904df96bd0031c9469e61118da5200 (patch) | |
tree | af7a870a3b4490f521d5d8c87a182d8f63930698 /Tests | |
parent | 59f53f7422818f3ccad8518ab0863de6bb7fd293 (diff) | |
parent | ad140c6e1bb6eda5d17a199304578dbd92bedbad (diff) | |
download | CMake-5b2acf6c1c904df96bd0031c9469e61118da5200.zip CMake-5b2acf6c1c904df96bd0031c9469e61118da5200.tar.gz CMake-5b2acf6c1c904df96bd0031c9469e61118da5200.tar.bz2 |
Merge topic 'vs-startup-project'
ad140c6e VS: Put ALL_BUILD in the PREDEFINED_TARGETS_FOLDER
f069be05 VS: Fix default target support for targets nested inside a folder
c05ea485 VS: Improve unit test macros
78ec0461 VS: Add option to choose the `.sln` startup project (#15578)
Diffstat (limited to 'Tests')
10 files changed, 54 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 048b5e3..d22c39c 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -235,7 +235,10 @@ endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") add_RunCMake_test(include_external_msproject) - add_RunCMake_test(VSSolution) + if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([789]|10)" AND NOT CMAKE_VS_DEVENV_COMMAND) + set(NO_USE_FOLDERS 1) + endif() + add_RunCMake_test(VSSolution -DNO_USE_FOLDERS=${NO_USE_FOLDERS}) endif() if("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([^789]|[789][0-9])") diff --git a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake index 6ae158d..afd74a1 100644 --- a/Tests/RunCMake/VSSolution/RunCMakeTest.cmake +++ b/Tests/RunCMake/VSSolution/RunCMakeTest.cmake @@ -8,3 +8,9 @@ run_cmake(MorePost) run_cmake(PrePost) run_cmake(Override1) run_cmake(Override2) +run_cmake(StartupProject) +run_cmake(StartupProjectMissing) + +if(RunCMake_GENERATOR MATCHES "Visual Studio ([^7]|[7][0-9])" AND NOT NO_USE_FOLDERS) + run_cmake(StartupProjectUseFolders) +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject-check.cmake b/Tests/RunCMake/VSSolution/StartupProject-check.cmake new file mode 100644 index 0000000..f36aab2 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject-check.cmake @@ -0,0 +1,5 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "TestStartup") + error("TestStartup is not the startup project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProject.cmake b/Tests/RunCMake/VSSolution/StartupProject.cmake new file mode 100644 index 0000000..7192f3d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProject.cmake @@ -0,0 +1,2 @@ +add_custom_target(TestStartup) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake new file mode 100644 index 0000000..b1017dd --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-check.cmake @@ -0,0 +1,5 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "ALL_BUILD") + error("ALL_BUILD is not the startup project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt new file mode 100644 index 0000000..da92c6d --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing-stderr.txt @@ -0,0 +1,4 @@ +^CMake Warning \(dev\) in CMakeLists.txt: + Directory property VS_STARTUP_PROJECT specifies target 'DoesNotExist' that + does not exist. Ignoring. +This warning is for project developers. Use -Wno-dev to suppress it.$ diff --git a/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake new file mode 100644 index 0000000..907a877 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectMissing.cmake @@ -0,0 +1 @@ +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "DoesNotExist") diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake new file mode 100644 index 0000000..c0a545a --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders-check.cmake @@ -0,0 +1,9 @@ +getProjectNames(projects) +list(GET projects 0 first_project) +if(NOT first_project STREQUAL "CMakePredefinedTargets") + error("CMakePredefinedTargets is not the first project") +endif() +list(GET projects 1 second_project) +if(NOT second_project STREQUAL "TestStartup") + error("TestStartup does not immediately follow the CMakePredefinedTargets project") +endif() diff --git a/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake new file mode 100644 index 0000000..8e422a4 --- /dev/null +++ b/Tests/RunCMake/VSSolution/StartupProjectUseFolders.cmake @@ -0,0 +1,3 @@ +add_custom_target(TestStartup) +set_property(GLOBAL PROPERTY USE_FOLDERS ON) +set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT "TestStartup") diff --git a/Tests/RunCMake/VSSolution/solution_parsing.cmake b/Tests/RunCMake/VSSolution/solution_parsing.cmake index dd158ef..4e5bb59 100644 --- a/Tests/RunCMake/VSSolution/solution_parsing.cmake +++ b/Tests/RunCMake/VSSolution/solution_parsing.cmake @@ -50,6 +50,21 @@ macro(parseGlobalSections arg_out_pre arg_out_post testName) endmacro() +macro(getProjectNames arg_out_projects) + set(${arg_out_projects} "") + set(sln "${RunCMake_TEST_BINARY_DIR}/${test}.sln") + if(NOT EXISTS "${sln}") + error("Expected solution file ${sln} does not exist") + endif() + file(STRINGS "${sln}" project_lines REGEX "^Project\\(") + foreach(project_line IN LISTS project_lines) + string(REGEX REPLACE ".* = \"" "" project_line "${project_line}") + string(REGEX REPLACE "\", .*" "" project_line "${project_line}") + list(APPEND ${arg_out_projects} "${project_line}") + endforeach() +endmacro() + + macro(testGlobalSection prefix sectionName) if(NOT DEFINED ${prefix}_${sectionName}) error("Section ${sectionName} does not exist") |