View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0001789CMakepublic2005-04-22 10:032005-04-22 22:53
ReporterAndrey 
Assigned ToBrad King 
PrioritylowSeverityminorReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0001789: MakefileGenerator "jump-and-build" dependencies issue
DescriptionIn my project based on ACE, i'm using tao_idl generator which generates header and source files from idl. Then some files compiled into library (dynamic or static) and other parts of project include some of generated files and links agains library which generates them (via ADD_CUSTOM_COMMAND f.e.). From top build all work ok. But when I want to compile only one of subprojects in clean build tree compilation fails. Library which generate files exists in deps for desired project, but Makefile begin to compile source files before library. This leads to "no such file". Soulution will be to place dependencies before *_SRC_OBJ and *_EXTERNAL_OBJ in Makefile's rules. In this case all deps will be built before any of source files will be compiled.

Test project provided:
If you wan't to compile from app1 dir you will fail. But with my patch all work fine. First lib1 will be built and then all source file and app1 finally.


Patch
=========================================================
--- Source/cmLocalUnixMakefileGenerator.cxx 2004-10-27 23:58:46.000000000 +0400
+++ ../../cmake/cmake-2.0.5/Source/cmLocalUnixMakefileGenerator.cxx 2005-04-22 17:02:34.000000000 +0400
@@ -1161,7 +1161,7 @@
   std::string objsQuoted = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS_QUOTED") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS_QUOTED") + ") ";
   // create a variable with the objects that this library depends on
   std::string depend =
- objs + " $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
+ " $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")" + objs;
 
   std::vector<std::string> commands;
   std::string cmakecommand = this->ConvertToOutputForExisting(
@@ -1428,10 +1428,8 @@
     needsLocalTarget = true;
     }
   std::string objs = "$(" + this->CreateMakeVariable(name, "_SRC_OBJS") + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS") + ") ";
- std::string depend = "$(";
- depend += this->CreateMakeVariable(name, "_SRC_OBJS")
- + ") $(" + this->CreateMakeVariable(name, "_EXTERNAL_OBJS")
- + ") $(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ")";
+ std::string depend = "$(" + this->CreateMakeVariable(name, "_DEPEND_LIBS") + ") " + objs ;
+
   std::vector<std::string> rules;
   linkFlags += m_Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
   linkFlags += " ";
=========================================================
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0002359)
Brad King (manager)
2005-04-22 11:49

I cannot reproduce the error with your example project in the tarball. I tried make from the top, from lib1, and from app1, each time from a freshly generated build tree. It does not produce an error.

It looks like your lib1 directory contains
CONFIGURE_FILE(
  ${CMAKE_CURRENT_SOURCE_DIR}/lib1.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/lib1.h
  )
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/lib1.h PROPERTIES GENERATED 1)
ADD_LIBRARY(lib1 lib1.cxx)

The CONFIGURE_FILE command is a CMake-time operation so the file lib1.h is not really generated. If you replace it with a custom command to do the generation then you can get this dependency added by using

SET_SOURCE_FILES_PROPERTIES(lib1.cxx PROPERTIES
  OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/lib1.h)

That will make sure the dependency to drive the custom command is present.

Your proposed patch switches the order of the dependencies to make sure the jump-and-build occurs first. This will not work for a parallel build (make -j2). In order to support parallel builds one can never depend on the order of dependencies as they are listed in the makefile. The dependencies must be setup to work no matter the order listed.

 Issue History
Date Modified Username Field Change


Copyright © 2000 - 2018 MantisBT Team