From 1ca93182ad37f6f90ceb0b2a5faaa21ef58ba7e2 Mon Sep 17 00:00:00 2001 From: Petr Kmoch Date: Thu, 3 Jan 2013 13:43:42 +0100 Subject: VS: Add test for building MSBuild project in subdir Add test covering cmGlobalGenerator::GenerateBuildCommand for VS solutions with MSBuild and building a target defined in a subdirectory and not part of ALL. --- Tests/CMakeLists.txt | 23 +++++++++++++++++++++++ Tests/VSProjectInSubdir/CMakeLists.txt | 3 +++ Tests/VSProjectInSubdir/subdir/CMakeLists.txt | 1 + 3 files changed, 27 insertions(+) create mode 100644 Tests/VSProjectInSubdir/CMakeLists.txt create mode 100644 Tests/VSProjectInSubdir/subdir/CMakeLists.txt diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index e07bb69..4eb2f90 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1495,6 +1495,29 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ unset(_last_test) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild") endif() + + if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])") + if(CMAKE_TEST_MAKEPROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") + set(MSBUILD_EXECUTABLE "${CMAKE_TEST_MAKEPROGRAM}") + else() + set(_FDIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;FrameworkDir32]") + set(_FVER "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VC7;FrameworkVer32]") + find_program(MSBUILD_EXECUTABLE NAMES msbuild HINTS ${_FDIR}/${_FVER}) + endif() + if(MSBUILD_EXECUTABLE) + add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir" + "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir" + --build-two-config + --build-generator ${CMAKE_TEST_GENERATOR} + --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}" + --build-makeprogram "${MSBUILD_EXECUTABLE}" + --build-project VSProjectInSubdir + --build-target test) + list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir") + endif() + endif() endif() if (APPLE) diff --git a/Tests/VSProjectInSubdir/CMakeLists.txt b/Tests/VSProjectInSubdir/CMakeLists.txt new file mode 100644 index 0000000..c164a97 --- /dev/null +++ b/Tests/VSProjectInSubdir/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 2.8.10) +project(VSProjectInSubdir NONE) +add_subdirectory(subdir) diff --git a/Tests/VSProjectInSubdir/subdir/CMakeLists.txt b/Tests/VSProjectInSubdir/subdir/CMakeLists.txt new file mode 100644 index 0000000..6c1b6a1 --- /dev/null +++ b/Tests/VSProjectInSubdir/subdir/CMakeLists.txt @@ -0,0 +1 @@ +add_custom_target(test COMMAND ${CMAKE_COMMAND} -E echo test VERBATIM) -- cgit v0.12