MantisBT - CMake
View Issue Details
0006193CMakeCMakepublic2007-12-21 09:212008-01-10 15:18
Nicolas Tisserand 
 
normalmajoralways
closedfixed 
 
 
0006193: XCode generator produces projects that do not handle correctly handle certain dependency patterns
Hi,

I'm working on a C++ project that's been happily using CMake as a
cross-platform (mac/pc/linux) build tool for a year now.

We're using CMake 2.4.6 on all platforms.

Recently, some changes in our build system lead to the following
dependency graph:

LIB1 <- EXE1 <- LIB2 <- EXE2
  ^ |
   `---------------------'

(LIB* are static libraries, and EXE* executables)

EXE1 is a tool that generates input source files for LIB2, hence the
extra-dependency.

Everything works nice and smooth with the Linux / Make, MacOS X / Make
and WIN32 / VC80 generators.

Trouble is, on the mac, the XCODE_DEPEND_HELPER (XDH) is added to all
final (executable, dynamic libraries and modules) targets by the XCode
generator:

  .-----------------------------
  v \
LIB1 <-------. |
              EXE1 <- LIB2 <- EXE2
XDH <-------' |
  ^------------------------------'

When EXE2 (or ALL_BUILD) is the active target and LIB2 needs a
rebuild, the following happens:

* The XCODE_DEPEND_HELPER make command is run, doing nothing.
* EXE1 is left alone
* LIB2 gets correctly rebuilt
* EXE2 does not get relinked because when XCODE_DEPEND_HELPER was run,
EXE2 was still up-to-date with LIB2 :-(

This is very annoying.

Here's the only sort-of workaround I could come up with:

* remove the EXE1 <- LIB2 dependency, so that EXE2 gets correctly
relinked when the active target is EXE2
* exclude EXE1 from the build (using EXCLUDE_FROM_ALL), so that EXE2
gets correctly relinked when the active target is ALL_BUILD

But this forces XCode users to rebuild EXE1 manually.
Please find attached a minimal example project that you can use to reproduce the behavior. There is a README.txt inside the archive, with detailed instructions.
No tags attached.
gz CMakeBug.tar.gz (1,155) 2007-12-21 09:21
https://public.kitware.com/Bug/file/1266/CMakeBug.tar.gz
Issue History
2007-12-21 09:21Nicolas TisserandNew Issue
2007-12-21 09:21Nicolas TisserandFile Added: CMakeBug.tar.gz
2008-01-02 18:03Bill HoffmanNote Added: 0010052
2008-01-10 15:18Bill HoffmanNote Added: 0010106
2008-01-10 15:18Bill HoffmanStatusnew => closed
2008-01-10 15:18Bill HoffmanResolutionopen => fixed

Notes
(0010052)
Bill Hoffman   
2008-01-02 18:03   
I think the trick maybe to remove the XCODE_DEPEND_HELPER target, and make a Run script that runs after each target is built that runs the make command to check the depends. I did this by hand and it seemed to work. I will try and implement it soon in CMake.
(0010106)
Bill Hoffman   
2008-01-10 15:18   
OK, I fixed this in CVS CMake. It won't make it into 2.4.8, but will be in 2.6. Thanks for the complete bug report. If you use CVS CMake, your test should work now.