Merge topic 'normalize-custom-command-paths'

c4af46b4 add_custom_command: Normalize OUTPUT and DEPENDS paths.
This commit is contained in:
Brad King 2014-05-29 09:58:47 -04:00 committed by CMake Topic Stage
commit 8afbb346c6
3 changed files with 42 additions and 1 deletions

View File

@ -173,6 +173,10 @@ bool cmAddCustomCommandCommand
break; break;
} }
if (cmSystemTools::FileIsFullPath(filename.c_str()))
{
filename = cmSystemTools::CollapseFullPath(filename);
}
switch (doing) switch (doing)
{ {
case doing_working_directory: case doing_working_directory:

View File

@ -103,8 +103,18 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
{ {
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
= this->GE->Parse(*i); = this->GE->Parse(*i);
std::vector<std::string> result;
cmSystemTools::ExpandListArgument( cmSystemTools::ExpandListArgument(
cge->Evaluate(this->Makefile, this->Config), this->Depends); cge->Evaluate(this->Makefile, this->Config), result);
for (std::vector<std::string>::iterator it = result.begin();
it != result.end(); ++it)
{
if (cmSystemTools::FileIsFullPath(it->c_str()))
{
*it = cmSystemTools::CollapseFullPath(*it);
}
}
this->Depends.insert(this->Depends.end(), result.begin(), result.end());
} }
} }
return this->Depends; return this->Depends;

View File

@ -456,3 +456,30 @@ add_custom_target(source_in_custom_target SOURCES source_in_custom_target.cpp)
set_property(SOURCE source_in_custom_target set_property(SOURCE source_in_custom_target
PROPERTY COMPILE_DEFINITIONS "TEST" PROPERTY COMPILE_DEFINITIONS "TEST"
) )
set(gen_path "${CMAKE_CURRENT_BINARY_DIR}//./foo")
set(gen_file "${gen_path}/foo.cxx")
add_custom_command(
OUTPUT "${gen_file}"
# Make sure the output directory exists before trying to write to it.
COMMAND ${CMAKE_COMMAND} -E make_directory "${gen_path}"
COMMAND ${CMAKE_COMMAND} -E touch "${gen_file}"
)
add_library(NormOutput "${gen_file}")
set(gen_path "${gen_path}/bar")
set(gen_file "${gen_path}/bar.cxx")
add_custom_command(
OUTPUT "${gen_path}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${gen_path}"
)
add_custom_command(
OUTPUT "${gen_file}"
DEPENDS "${gen_path}"
COMMAND ${CMAKE_COMMAND} -E touch "${gen_file}")
add_library(NormDepends "${gen_file}")