file(INSTALL): Report existing DIRECTORY as Up-to-date
Teach cmFileCopier::InstallDirectory to detect whether the destination directory exists. If so, report it as "Up-to-date" instead of "Installing". This resolves message asymmetry with file installations. Extend the RunCMake.file and RunCMake.install tests to check the installation output on both the first and second run. Suggested-by: J Decker <d3ck0r@gmail.com>
This commit is contained in:
parent
f701b0b7f7
commit
464567a577
|
@ -1613,7 +1613,8 @@ bool cmFileCopier::InstallDirectory(const char* source,
|
||||||
MatchProperties const& match_properties)
|
MatchProperties const& match_properties)
|
||||||
{
|
{
|
||||||
// Inform the user about this directory installation.
|
// Inform the user about this directory installation.
|
||||||
this->ReportCopy(destination, TypeDir, true);
|
this->ReportCopy(destination, TypeDir,
|
||||||
|
!cmSystemTools::FileIsDirectory(destination));
|
||||||
|
|
||||||
// Make sure the destination directory exists.
|
// Make sure the destination directory exists.
|
||||||
if(!cmSystemTools::MakeDirectory(destination))
|
if(!cmSystemTools::MakeDirectory(destination))
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
-- Before Installing
|
||||||
|
-- Installing: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir
|
||||||
|
-- Installing: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt
|
||||||
|
-- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir
|
||||||
|
-- Up-to-date: .*/Tests/RunCMake/file/INSTALL-DIRECTORY-build/dir/empty.txt
|
||||||
|
-- After Installing
|
|
@ -0,0 +1,7 @@
|
||||||
|
set(src ${CMAKE_CURRENT_SOURCE_DIR}/dir)
|
||||||
|
set(dst ${CMAKE_CURRENT_BINARY_DIR}/dir)
|
||||||
|
file(REMOVE RECURSE ${dst})
|
||||||
|
message(STATUS "Before Installing")
|
||||||
|
file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY)
|
||||||
|
file(INSTALL FILES ${src}/ DESTINATION ${dst} TYPE DIRECTORY)
|
||||||
|
message(STATUS "After Installing")
|
|
@ -1,3 +1,4 @@
|
||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
|
||||||
|
run_cmake(INSTALL-DIRECTORY)
|
||||||
run_cmake(FileOpenFailRead)
|
run_cmake(FileOpenFailRead)
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
file(REMOVE_RECURSE ${RunCMake_TEST_BINARY_DIR}/prefix)
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
|
||||||
|
OUTPUT_VARIABLE out ERROR_VARIABLE err)
|
||||||
|
set(expect "
|
||||||
|
-- Installing: [^\n]*/prefix/dir\r?
|
||||||
|
-- Installing: [^\n]*/prefix/dir/empty.txt\r?
|
||||||
|
")
|
||||||
|
if(NOT out MATCHES "${expect}")
|
||||||
|
string(REGEX REPLACE "\n" "\n " out " ${out}")
|
||||||
|
set(RunCMake_TEST_FAILED
|
||||||
|
"${RunCMake_TEST_FAILED}First install did not say 'Installing' as expected:\n${out}")
|
||||||
|
endif()
|
||||||
|
set(f ${RunCMake_TEST_BINARY_DIR}/prefix/dir/empty.txt)
|
||||||
|
if(NOT EXISTS "${f}")
|
||||||
|
set(RunCMake_TEST_FAILED
|
||||||
|
"${RunCMake_TEST_FAILED}File was not installed:\n ${f}\n")
|
||||||
|
endif()
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -P ${RunCMake_TEST_BINARY_DIR}/cmake_install.cmake
|
||||||
|
OUTPUT_VARIABLE out ERROR_VARIABLE err)
|
||||||
|
set(expect "
|
||||||
|
-- Up-to-date: [^\n]*/prefix/dir\r?
|
||||||
|
-- Up-to-date: [^\n]*/prefix/dir/empty.txt\r?
|
||||||
|
")
|
||||||
|
if(NOT out MATCHES "${expect}")
|
||||||
|
string(REGEX REPLACE "\n" "\n " out " ${out}")
|
||||||
|
set(RunCMake_TEST_FAILED
|
||||||
|
"${RunCMake_TEST_FAILED}Second install did not say 'Up-to-date' as expected:\n${out}")
|
||||||
|
endif()
|
|
@ -0,0 +1,2 @@
|
||||||
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/prefix")
|
||||||
|
install(DIRECTORY dir/ DESTINATION dir)
|
|
@ -1,4 +1,5 @@
|
||||||
include(RunCMake)
|
include(RunCMake)
|
||||||
|
run_cmake(DIRECTORY-message)
|
||||||
run_cmake(SkipInstallRulesWarning)
|
run_cmake(SkipInstallRulesWarning)
|
||||||
run_cmake(SkipInstallRulesNoWarning1)
|
run_cmake(SkipInstallRulesNoWarning1)
|
||||||
run_cmake(SkipInstallRulesNoWarning2)
|
run_cmake(SkipInstallRulesNoWarning2)
|
||||||
|
|
Loading…
Reference in New Issue