Merge topic 'vs-install-in-default-build'

a6e4e73d VS: Add option to put INSTALL target in .sln default build
562e69dd Tests: Enable devenv tests on VS >= 10
This commit is contained in:
Brad King 2015-05-07 14:25:37 -04:00 committed by CMake Topic Stage
commit 18527c4991
8 changed files with 52 additions and 1 deletions

View File

@ -268,6 +268,7 @@ Variables that Control the Build
/variable/CMAKE_TRY_COMPILE_CONFIGURATION /variable/CMAKE_TRY_COMPILE_CONFIGURATION
/variable/CMAKE_USE_RELATIVE_PATHS /variable/CMAKE_USE_RELATIVE_PATHS
/variable/CMAKE_VISIBILITY_INLINES_HIDDEN /variable/CMAKE_VISIBILITY_INLINES_HIDDEN
/variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
/variable/CMAKE_WIN32_EXECUTABLE /variable/CMAKE_WIN32_EXECUTABLE
/variable/CMAKE_XCODE_ATTRIBUTE_an-attribute /variable/CMAKE_XCODE_ATTRIBUTE_an-attribute
/variable/EXECUTABLE_OUTPUT_PATH /variable/EXECUTABLE_OUTPUT_PATH

View File

@ -0,0 +1,7 @@
vs-install-in-default-build
---------------------------
* The :ref:`Visual Studio Generators` learned a new
:variable:`CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD` option
to put the ``INSTALL`` target in the default build of a
solution (``.sln``) file.

View File

@ -0,0 +1,8 @@
CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
-----------------------------------------
Include INSTALL target to default build.
In Visual Studio solution, by default the INSTALL target will not be part of
the default build. Setting this variable will enable the INSTALL target to be
part of the default build.

View File

@ -1031,6 +1031,24 @@ cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
int type = target->GetType(); int type = target->GetType();
if (type == cmTarget::GLOBAL_TARGET) if (type == cmTarget::GLOBAL_TARGET)
{ {
// check if INSTALL target is part of default build
if(target->GetName() == "INSTALL")
{
// inspect CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD properties
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
{
const char* propertyValue = target->GetMakefile()
->GetDefinition("CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD");
cmGeneratorExpression ge;
cmsys::auto_ptr<cmCompiledGeneratorExpression>
cge = ge.Parse(propertyValue);
if(cmSystemTools::IsOn(cge->Evaluate(target->GetMakefile(), *i)))
{
activeConfigs.insert(*i);
}
}
}
return activeConfigs; return activeConfigs;
} }
if(type == cmTarget::UTILITY && !this->IsDependedOn(projectTargets, target)) if(type == cmTarget::UTILITY && !this->IsDependedOn(projectTargets, target))

View File

@ -46,7 +46,9 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
# Testing # Testing
if(BUILD_TESTING) if(BUILD_TESTING)
set(CMake_TEST_DEVENV "") set(CMake_TEST_DEVENV "")
if(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND if(CMAKE_VS_DEVENV_COMMAND)
set(CMake_TEST_DEVENV "${CMAKE_VS_DEVENV_COMMAND}")
elseif(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND
NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]") NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}") set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
endif() endif()
@ -1869,6 +1871,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--build-generator-platform "${CMAKE_GENERATOR_PLATFORM}" --build-generator-platform "${CMAKE_GENERATOR_PLATFORM}"
--build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}" --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project VSExcludeFromDefaultBuild --build-project VSExcludeFromDefaultBuild
--build-target install
--test-command ${CMAKE_COMMAND} --test-command ${CMAKE_COMMAND}
-D "activeConfig=${config}" -D "activeConfig=${config}"
-D "allConfigs=${CMAKE_CONFIGURATION_TYPES}" -D "allConfigs=${CMAKE_CONFIGURATION_TYPES}"

View File

@ -1,6 +1,9 @@
cmake_minimum_required(VERSION 2.8.9) cmake_minimum_required(VERSION 2.8.9)
project(VSExcludeFromDefaultBuild) project(VSExcludeFromDefaultBuild)
# CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD will enable the INSTALL target to be part of the default build
set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1)
# First step is to clear all .exe files in output so that possible past # First step is to clear all .exe files in output so that possible past
# failures of this test do not prevent it from succeeding. # failures of this test do not prevent it from succeeding.
add_custom_target(ClearExes ALL add_custom_target(ClearExes ALL
@ -13,6 +16,7 @@ add_custom_target(ClearExes ALL
function(add_test_executable target) function(add_test_executable target)
add_executable("${target}" ${ARGN}) add_executable("${target}" ${ARGN})
add_dependencies("${target}" ClearExes) add_dependencies("${target}" ClearExes)
install(TARGETS "${target}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/install" OPTIONAL)
endfunction() endfunction()
add_test_executable(DefaultBuilt main.c) add_test_executable(DefaultBuilt main.c)

View File

@ -2,3 +2,7 @@ file(GLOB exeFiles "${dir}/*.exe")
foreach(exeFile IN LISTS exeFiles) foreach(exeFile IN LISTS exeFiles)
file(REMOVE "${exeFile}") file(REMOVE "${exeFile}")
endforeach() endforeach()
file(GLOB exeFiles "${dir}/install/*.exe")
foreach(exeFile IN LISTS exeFiles)
file(REMOVE "${exeFile}")
endforeach()

View File

@ -7,6 +7,12 @@ macro(TestExists exeName)
else() else()
message(FATAL_ERROR "File ${exeFile} was expected ${ARGN} to exist!") message(FATAL_ERROR "File ${exeFile} was expected ${ARGN} to exist!")
endif() endif()
set(exeFile "${dir}/${activeConfig}/install/${exeName}.exe")
if(${ARGN} EXISTS "${exeFile}")
message(STATUS "File ${exeFile} was correctly found ${ARGN} to exist.")
else()
message(FATAL_ERROR "File ${exeFile} was expected ${ARGN} to exist!")
endif()
endmacro() endmacro()
TestExists(DefaultBuilt) TestExists(DefaultBuilt)