View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014446CMakeCMakepublic2013-09-28 10:262014-03-05 09:58
ReporterStephen Kelly 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake 2.8.12 
Target VersionCMake 2.8.12Fixed in VersionCMake 2.8.12 
Summary0014446: Regression in cmMakefile::GetSourceFileWithOutput
DescriptionThe kde strigidaemon repo does not build with the next branch (and 2.8.12 RC).

 http://build.kde.org/view/kdesupport/job/strigidaemon_master/23/consoleText [^]


 [ 55%] [ 57%] Error copying file (if different) from "/srv/jenkins/workspace/strigidaemon_master/build/bin/daemon/dbus/dbusclientinterface.cpp" to "/srv/jenkins/workspace/strigidaemon_master/bin/daemon/dbus/generated/dbusclientinterface.cpp".
 make[2]: *** [bin/daemon/dbus/dbusclientinterface.cpp] Error 1
 make[2]: *** Waiting for unfinished jobs....
 Generating dbustestinterface.cpp
 Scanning dependencies of target strigicmd
 Building CXX object bin/daemon/xsd/CMakeFiles/strigidaemonconfiguration.dir/strigidaemonconfiguration.cpp.o
 Error copying file (if different) from "/srv/jenkins/workspace/strigidaemon_master/build/bin/daemon/dbus/dbustestinterface.cpp" to "/srv/jenkins/workspace/strigidaemon_master/bin/daemon/dbus/generated/dbustestinterface.cpp".
 [ 59%] make[2]: *** [bin/daemon/dbus/dbustestinterface.cpp] Error 1
 make[1]: *** [bin/daemon/dbus/CMakeFiles/dbusserver.dir/all] Error 2
 make[1]: *** Waiting for unfinished jobs....
 [ 59%] Building CXX object bin/strigicmd/CMakeFiles/strigicmd.dir/strigicmd.cpp.o

It builds prior to commit 2268c41a057d948 (Optimize custom command full-path dependency lookup, 2013-08-06).

It also builds with the following patch:

 diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index fd06a33..2aea078 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2094,7 +2094,7 @@ cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname)
 
   // If the queried path is not absolute we use the backward compatible
   // linear-time search for an output with a matching suffix.
- if(!cmSystemTools::FileIsFullPath(cname))
+// if(!cmSystemTools::FileIsFullPath(cname))
     {
     return LinearGetSourceFileWithOutput(cname);
     }

The code is here:

 https://projects.kde.org/projects/kdesupport/strigi/strigidaemon/repository/revisions/master/entry/bin/daemon/dbus/CMakeLists.txt [^]

It looks buggy to me as in the perl-found branch (as taken by KDE jenkins), two custom commands have the same output file. A policy may be needed to choose the linear search in old behavior.
Steps To ReproduceThe problem can be reduced to this testcase:

 cmake_minimum_required(VERSION 2.8)

 execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/input.cpp")
 execute_process(COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_BINARY_DIR}/main_dep.h")

 add_custom_command(
     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.cpp"
     COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/input.cpp" "${CMAKE_CURRENT_BINARY_DIR}/output.cpp"
     MAIN_DEPENDENCY "${CMAKE_CURRENT_BINARY_DIR}/main_dep.h"
 )
 add_custom_command(
     OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output.cpp"
     COMMAND ${CMAKE_COMMAND} -E copy_if_different
         "${CMAKE_CURRENT_BINARY_DIR}/output.cpp"
         "${CMAKE_CURRENT_SOURCE_DIR}/final_output.cpp"
 )

 add_library(dbusserver STATIC
     "${CMAKE_CURRENT_BINARY_DIR}/output.cpp"
 )

If the MAIN_DEPENDENCY line is commented out, an error is reported at CMake time.
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0033934)
Brad King (manager)
2013-09-30 09:08

With MAIN_DEPENDENCY commented out the example fails with 2.8.11.2 also:

$ cmake --version
cmake version 2.8.11.2

$ cat ../CMakeLists.txt
cmake_minimum_required(VERSION 2.8)
project(Issue14446 CXX)
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output.cpp
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_SOURCE_DIR}/input.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/output.cpp
  #MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/main_dep.h
  )
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/output.cpp
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
    ${CMAKE_CURRENT_BINARY_DIR}/output.cpp
    ${CMAKE_CURRENT_BINARY_DIR}/final_output.cpp
  )
add_library(dbusserver STATIC ${CMAKE_CURRENT_BINARY_DIR}/output.cpp)

$ cmake ..
CMake Error: Attempt to add a custom rule to output ".../output.cpp.rule" which already has a custom rule.

Since the real use case has a MAIN_DEPENDENCY for at least one of the commands there must be a different minimum example.
(0033935)
Brad King (manager)
2013-09-30 09:15

Here is an example adapted from the linked code that reproduces the issue:
cmake_minimum_required(VERSION 2.8)
project(Issue14446 CXX)
add_custom_command(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/test.h
          ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test.h.in
                                   ${CMAKE_CURRENT_BINARY_DIR}/test.h
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp.in
                                   ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/test.h.in
  )
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test.h
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
  ${CMAKE_CURRENT_BINARY_DIR}/test.h
  ${CMAKE_CURRENT_SOURCE_DIR}/generated/test.h
  )
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
  ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/generated/test.cpp
  )
add_library(dbusserver STATIC
  ${CMAKE_CURRENT_BINARY_DIR}/test.h
  ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  )
(0033936)
Brad King (manager)
2013-09-30 09:21

The KDE code in question is definitely buggy for having two rules with the same output. In fact if I switch the order of add_custom_command calls:
 
cmake_minimum_required(VERSION 2.8)
project(Issue14446 CXX)
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test.h
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
  ${CMAKE_CURRENT_BINARY_DIR}/test.h
  ${CMAKE_CURRENT_SOURCE_DIR}/generated/test.h
  )
add_custom_command(
  OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  COMMAND ${CMAKE_COMMAND} -E copy_if_different
  ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  ${CMAKE_CURRENT_SOURCE_DIR}/generated/test.cpp
  )
add_custom_command(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/test.h
          ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test.h.in
                                   ${CMAKE_CURRENT_BINARY_DIR}/test.h
  COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/test.cpp.in
                                   ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/test.h.in
  )
add_library(dbusserver STATIC
  ${CMAKE_CURRENT_BINARY_DIR}/test.h
  ${CMAKE_CURRENT_BINARY_DIR}/test.cpp
  )


then it fails with 2.8.11.2 in the exact same way.
(0033937)
Brad King (manager)
2013-09-30 09:55

Fixed:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=68bfed63 [^]
(0033948)
Brad King (manager)
2013-09-30 15:00

This fails in the VS 8 generator:

 http://open.cdash.org/testDetails.php?test=210961145&build=3044201 [^]

because it uses separate generate.stamp rules in ZERO_CHECK and the individual targets:

 CMake Warning (dev) in CMakeLists.txt:
   Attempt to add a custom command to generate

     .../CMakeFiles/generate.stamp

   but source file "generate.stamp.rule" already has a custom command to
   generate it.
 This warning is for project developers. Use -Wno-dev to suppress it.

We will have to drop the warning for now and just go with the keep-first-mapping approach.
(0033949)
Brad King (manager)
2013-09-30 15:02

I reverted the warning part:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3e888cac [^]
(0033950)
Brad King (manager)
2013-09-30 15:06

The squashed commit:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dccd4949 [^]
(0035272)
Robert Maynard (manager)
2014-03-05 09:58

Closing resolved issues that have not been updated in more than 4 months

 Issue History
Date Modified Username Field Change
2013-09-28 10:26 Stephen Kelly New Issue
2013-09-28 10:26 Stephen Kelly Status new => assigned
2013-09-28 10:26 Stephen Kelly Assigned To => Brad King
2013-09-30 09:08 Brad King Note Added: 0033934
2013-09-30 09:15 Brad King Note Added: 0033935
2013-09-30 09:21 Brad King Note Added: 0033936
2013-09-30 09:55 Brad King Note Added: 0033937
2013-09-30 09:55 Brad King Status assigned => resolved
2013-09-30 09:55 Brad King Resolution open => fixed
2013-09-30 09:55 Brad King Fixed in Version => CMake 2.8.12
2013-09-30 09:55 Brad King Description Updated
2013-09-30 09:55 Brad King Steps to Reproduce Updated
2013-09-30 15:00 Brad King Note Added: 0033948
2013-09-30 15:00 Brad King Status resolved => assigned
2013-09-30 15:00 Brad King Resolution fixed => open
2013-09-30 15:02 Brad King Note Added: 0033949
2013-09-30 15:06 Brad King Note Added: 0033950
2013-09-30 15:07 Brad King Status assigned => resolved
2013-09-30 15:07 Brad King Resolution open => fixed
2014-03-05 09:58 Robert Maynard Note Added: 0035272
2014-03-05 09:58 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team