Re: [CMake] Problems with parallel builds

2010-11-18 Thread Marcel Loose
 On 18-11-2010 at 13:06, in message
306960.51089...@web65407.mail.ac4.yahoo.com, Denis Scherbakov
denis_scherba...@yahoo.com wrote: 
 Dear All,
 
 I am using CMake 2.8.1 on Linux x86. I have a project that needs to
be built 
 two times. One with -fPIC, the other - without. The project depends
on header 
 files that need to be generated by an external script.
 
 When I build this project with several parallel jobs (gmake -j5, for
example) 
 to my disappointment CMake calls external script several times so at
the end 
 I get corrupted header files.
 
 Does anybody know a cross-platform way of implementing a mutex (or
something 
 like that) to make sure that scripts that generate files are called
only 
 once?
 
 So far for me parallel builds do not work with CMake at all. 
 
 Thanks.
 Denis
 
 
   
 ___
 Powered by www.kitware.com
 
 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html
 
 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ
 
 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake

Hi Denis,

If you have two different build directories, which you need to have
anyway when compiling with and without -fPIC, then you shouldn't have a
problem, as long as you generate those header files in the build
directory, which is IMHO the only sensible place to put generated files
(your source tree might even be read-only!). Or maybe I completely
misunderstood your question.

Best regards,
Marcel Loose.

___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Eric Noulard
2010/11/18 Denis Scherbakov denis_scherba...@yahoo.com:
 Dear All,

 I am using CMake 2.8.1 on Linux x86. I have a project that needs to be built 
 two times. One with -fPIC, the other - without. The project depends on header 
 files that need to be generated by an external script.

 When I build this project with several parallel jobs (gmake -j5, for example) 
 to my disappointment CMake calls external script several times so at the end 
 I get corrupted header files.

Could you give us the exact CMake rule/command you use to generate
those headers?

configure_file?
add_custom_command?
add_custom_target?
execute_process?
... combination of those ?

 Does anybody know a cross-platform way of implementing a mutex (or something 
 like that) to make sure that
 scripts that generate files are called only once?

 So far for me parallel builds do not work with CMake at all.

I did never had any trouble with parallel building with CMake on Linux
with makefile generator so far.
For build host ranging from 1 processors to 4 processors with various -j values.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Denis Scherbakov
Hi!

What I mean is:

PROJECT(MYPROJECT)

ADD_CUSTOM_COMMAND( OUTPUT ${PROJECT_BINARY_DIR}/MyFile.hh COMMAND 
${CMAKE_COMMAND} -P MyScript.cmake)

SET_SOURCE_FILE_PROPERTIES(${PROJECT_BINARY_DIR}/MyFile.hh PROPERTIES 
GENERATED TRUE HEADER_FILE_ONLY TRUE)

SET (MYPROJECT_SRCS
  MyFile.hh
  MyFile.cc
)

ADD_LIBRARY(MYLIB ${MYPROJECT_SRCS})
ADD_LIBRARY(MYLIBpic ${MYPROJECT_SRCS})
SET_TARGET_PROPERTIES(MYLIBpic PROPERTIES COMPILE_FLAGS -FPIC -DPIC)

$ gmake -j2 all
... MyFile.hh is written two times

So far I understand two targets try to generate MyFile.hh at the same time and 
there is no way to tell one of them that the file is being built by someone 
else already.

Denis

--- On Thu, 11/18/10, Eric Noulard eric.noul...@gmail.com wrote:

 From: Eric Noulard eric.noul...@gmail.com
 Subject: Re: [CMake] Problems with parallel builds
 To: Denis Scherbakov denis_scherba...@yahoo.com
 Cc: cmake@cmake.org
 Date: Thursday, November 18, 2010, 5:13 AM
 2010/11/18 Denis Scherbakov denis_scherba...@yahoo.com:
  Dear All,
 
  I am using CMake 2.8.1 on Linux x86. I have a project
 that needs to be built two times. One with -fPIC, the other
 - without. The project depends on header files that need to
 be generated by an external script.
 
  When I build this project with several parallel jobs
 (gmake -j5, for example) to my disappointment CMake calls
 external script several times so at the end I get corrupted
 header files.
 
 Could you give us the exact CMake rule/command you use to
 generate
 those headers?
 
 configure_file?
 add_custom_command?
 add_custom_target?
 execute_process?
 ... combination of those ?
 
  Does anybody know a cross-platform way of implementing
 a mutex (or something like that) to make sure that
  scripts that generate files are called only once?
 
  So far for me parallel builds do not work with CMake
 at all.
 
 I did never had any trouble with parallel building with
 CMake on Linux
 with makefile generator so far.
 For build host ranging from 1 processors to 4 processors
 with various -j values.
 
 -- 
 Erk
 Membre de l'April - « promouvoir et défendre le logiciel
 libre » -
 http://www.april.org
 


  
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread David Cole
On Thu, Nov 18, 2010 at 8:34 AM, Denis Scherbakov
denis_scherba...@yahoo.com wrote:
 Hi!

 What I mean is:

 PROJECT(MYPROJECT)

 ADD_CUSTOM_COMMAND( OUTPUT ${PROJECT_BINARY_DIR}/MyFile.hh COMMAND 
 ${CMAKE_COMMAND} -P MyScript.cmake)

 SET_SOURCE_FILE_PROPERTIES(${PROJECT_BINARY_DIR}/MyFile.hh PROPERTIES 
 GENERATED TRUE HEADER_FILE_ONLY TRUE)

 SET (MYPROJECT_SRCS
  MyFile.hh
  MyFile.cc
 )

 ADD_LIBRARY(MYLIB ${MYPROJECT_SRCS})
 ADD_LIBRARY(MYLIBpic ${MYPROJECT_SRCS})
 SET_TARGET_PROPERTIES(MYLIBpic PROPERTIES COMPILE_FLAGS -FPIC -DPIC)

 $ gmake -j2 all
 ... MyFile.hh is written two times

 So far I understand two targets try to generate MyFile.hh at the same time 
 and there is no way to tell one of them that the file is being built by 
 someone else already.

 Denis

 --- On Thu, 11/18/10, Eric Noulard eric.noul...@gmail.com wrote:

 From: Eric Noulard eric.noul...@gmail.com
 Subject: Re: [CMake] Problems with parallel builds
 To: Denis Scherbakov denis_scherba...@yahoo.com
 Cc: cmake@cmake.org
 Date: Thursday, November 18, 2010, 5:13 AM
 2010/11/18 Denis Scherbakov denis_scherba...@yahoo.com:
  Dear All,
 
  I am using CMake 2.8.1 on Linux x86. I have a project
 that needs to be built two times. One with -fPIC, the other
 - without. The project depends on header files that need to
 be generated by an external script.
 
  When I build this project with several parallel jobs
 (gmake -j5, for example) to my disappointment CMake calls
 external script several times so at the end I get corrupted
 header files.

 Could you give us the exact CMake rule/command you use to
 generate
 those headers?

 configure_file?
 add_custom_command?
 add_custom_target?
 execute_process?
 ... combination of those ?

  Does anybody know a cross-platform way of implementing
 a mutex (or something like that) to make sure that
  scripts that generate files are called only once?
 
  So far for me parallel builds do not work with CMake
 at all.

 I did never had any trouble with parallel building with
 CMake on Linux
 with makefile generator so far.
 For build host ranging from 1 processors to 4 processors
 with various -j values.

 --
 Erk
 Membre de l'April - « promouvoir et défendre le logiciel
 libre » -
 http://www.april.org




 ___
 Powered by www.kitware.com

 Visit other Kitware open-source projects at 
 http://www.kitware.com/opensource/opensource.html

 Please keep messages on-topic and check the CMake FAQ at: 
 http://www.cmake.org/Wiki/CMake_FAQ

 Follow this link to subscribe/unsubscribe:
 http://www.cmake.org/mailman/listinfo/cmake


The easiest way to make this work is to have a separate custom target
that depends on the output of the custom command, and then to have the
two libraries depend on that custom target with add_dependencies...
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Denis Scherbakov
Hi, David,

I did as you suggested:

ADD_CUSTOM_COMMAND(OUTPUT MyFile.hh ...)
ADD_CUTSOM_TARGET(MyHeaders DEPENDS MyFile.hh)

ADD_LIBRARY(MYLIB ${MYLIB_SRCS})
ADD_DEPENDENCIES(MYLIB  MyHeaders)

ADD_LIBRARY(MYLIBpic ${MYLIB_SRCS})
ADD_DEPENDENCIES(MYLIBpic  MyHeaders)

Didn't work. Target MyHeaders is build two times when I do gmake -j2
I see two Generating MyFile.hh lines and MyFile.hh has duplicate lines.

Denis

 David Cole wrote:
 
 The easiest way to make this work is to have a separate
 custom target
 that depends on the output of the custom command, and then
 to have the
 two libraries depend on that custom target with
 add_dependencies...
 


  
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread David Cole
Try:
ADD_CUSTOM_TARGET(MyHeaders ALL DEPENDS MyFile.hh)

Without the ALL your target is not included in the set of targets
built by a make or a make all -- without your target included in
make there is nothing for the subsequent targets to depend on.
Perhaps we should add a warning to add_dependencies if expressing a
dependency on something not in all by default


On Thu, Nov 18, 2010 at 9:33 AM, Denis Scherbakov
denis_scherba...@yahoo.com wrote:
 Hi, David,

 I did as you suggested:

 ADD_CUSTOM_COMMAND(OUTPUT MyFile.hh ...)
 ADD_CUTSOM_TARGET(MyHeaders DEPENDS MyFile.hh)

 ADD_LIBRARY(MYLIB ${MYLIB_SRCS})
 ADD_DEPENDENCIES(MYLIB  MyHeaders)

 ADD_LIBRARY(MYLIBpic ${MYLIB_SRCS})
 ADD_DEPENDENCIES(MYLIBpic  MyHeaders)

 Didn't work. Target MyHeaders is build two times when I do gmake -j2
 I see two Generating MyFile.hh lines and MyFile.hh has duplicate lines.

 Denis

 David Cole wrote:

 The easiest way to make this work is to have a separate
 custom target
 that depends on the output of the custom command, and then
 to have the
 two libraries depend on that custom target with
 add_dependencies...





___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Denis Scherbakov
David,

Thank you for spending your time to resolve my problem.

Unfortunately you suggestion did not help.

Introduction of new custom targets in my case leads to the fact that
I have one custom target that depends on another custom target. I get:

gmake[3]: *** No rule to make target 'customTargetA', needed by 
'customTargetB'.  Stop.

And in this case it is not even a parallel build.

Now I remember that I already tried this custom-target trick about
a year ago and it failed with gmake error I specified above.

So CMake is not parallel build ready.
BTW, gmake -j4 targetA targetB also fails. You need to gmake -j4 targetA
and then gamake -j4 targetB to get correct results.

Denis

--- On Thu, 11/18/10, David Cole david.c...@kitware.com wrote:

 From: David Cole david.c...@kitware.com
 Subject: Re: [CMake] Problems with parallel builds
 To: Denis Scherbakov denis_scherba...@yahoo.com
 Cc: cmake@cmake.org
 Date: Thursday, November 18, 2010, 6:43 AM
 Try:
 ADD_CUSTOM_TARGET(MyHeaders ALL DEPENDS MyFile.hh)
 
 Without the ALL your target is not included in the set of
 targets
 built by a make or a make all -- without your target
 included in
 make there is nothing for the subsequent targets to
 depend on.
 Perhaps we should add a warning to add_dependencies if
 expressing a
 dependency on something not in all by default
 
 
 On Thu, Nov 18, 2010 at 9:33 AM, Denis Scherbakov
 denis_scherba...@yahoo.com
 wrote:
  Hi, David,
 
  I did as you suggested:
 
  ADD_CUSTOM_COMMAND(OUTPUT MyFile.hh ...)
  ADD_CUTSOM_TARGET(MyHeaders DEPENDS MyFile.hh)
 
  ADD_LIBRARY(MYLIB ${MYLIB_SRCS})
  ADD_DEPENDENCIES(MYLIB  MyHeaders)
 
  ADD_LIBRARY(MYLIBpic ${MYLIB_SRCS})
  ADD_DEPENDENCIES(MYLIBpic  MyHeaders)
 
  Didn't work. Target MyHeaders is build two times
 when I do gmake -j2
  I see two Generating MyFile.hh lines and MyFile.hh
 has duplicate lines.
 
  Denis
 
  David Cole wrote:
 
  The easiest way to make this work is to have a
 separate
  custom target
  that depends on the output of the custom command,
 and then
  to have the
  two libraries depend on that custom target with
  add_dependencies...
 
 
 
 
 
 


  
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Denis Scherbakov
Here is a sample CMakeLists.txt to illustrate that two custom targets cannot 
depend on each other:

PROJECT(BUG C)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

ADD_CUSTOM_COMMAND(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/fileOne
  COMMAND ${CMAKE_COMMAND}
 ARGS -E
  touch
  ${CMAKE_CURRENT_BINARY_DIR}/fileOne)

ADD_CUSTOM_TARGET(targetFileOne DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fileOne)

ADD_CUSTOM_COMMAND(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s
  COMMAND ${CMAKE_COMMAND}
 ARGS -E
  touch
  ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS targetFileOne 
${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

$ gmake
Scanning dependencies of target targetFileOne
[  0%] Generating fileOne
[ 50%] Built target targetFileOne
Scanning dependencies of target targetFileOneS
gmake[2]: *** No rule to make target `targetFileOne', needed by 
`CMakeFiles/targetFileOneS'.  Stop.
gmake[1]: *** [CMakeFiles/targetFileOneS.dir/all] Error 2
gmake: *** [all] Error 2

So I am back to my problem that I cannot compile my project in parallel.
The question is: How to implement mutexes in CMake scripts?

Denis

--- On Thu, 11/18/10, David Cole david.c...@kitware.com wrote:

 From: David Cole david.c...@kitware.com
 Subject: Re: [CMake] Problems with parallel builds
 To: Denis Scherbakov denis_scherba...@yahoo.com
 Cc: cmake@cmake.org
 Date: Thursday, November 18, 2010, 6:43 AM
 Try:
 ADD_CUSTOM_TARGET(MyHeaders ALL DEPENDS MyFile.hh)
 
 Without the ALL your target is not included in the set of
 targets
 built by a make or a make all -- without your target
 included in
 make there is nothing for the subsequent targets to
 depend on.
 Perhaps we should add a warning to add_dependencies if
 expressing a
 dependency on something not in all by default
 
 
 On Thu, Nov 18, 2010 at 9:33 AM, Denis Scherbakov
 denis_scherba...@yahoo.com
 wrote:
  Hi, David,
 
  I did as you suggested:
 
  ADD_CUSTOM_COMMAND(OUTPUT MyFile.hh ...)
  ADD_CUTSOM_TARGET(MyHeaders DEPENDS MyFile.hh)
 
  ADD_LIBRARY(MYLIB ${MYLIB_SRCS})
  ADD_DEPENDENCIES(MYLIB  MyHeaders)
 
  ADD_LIBRARY(MYLIBpic ${MYLIB_SRCS})
  ADD_DEPENDENCIES(MYLIBpic  MyHeaders)
 
  Didn't work. Target MyHeaders is build two times
 when I do gmake -j2
  I see two Generating MyFile.hh lines and MyFile.hh
 has duplicate lines.
 
  Denis
 
  David Cole wrote:
 
  The easiest way to make this work is to have a
 separate
  custom target
  that depends on the output of the custom command,
 and then
  to have the
  two libraries depend on that custom target with
  add_dependencies...
 
 
 
 
 
 


  
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread David Cole
On Thu, Nov 18, 2010 at 1:08 PM, Denis Scherbakov
denis_scherba...@yahoo.com wrote:
 Here is a sample CMakeLists.txt to illustrate that two custom targets cannot 
 depend on each other:

 PROJECT(BUG C)

 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

 ADD_CUSTOM_COMMAND(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/fileOne
  COMMAND ${CMAKE_COMMAND}
     ARGS -E
          touch
          ${CMAKE_CURRENT_BINARY_DIR}/fileOne)

 ADD_CUSTOM_TARGET(targetFileOne DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/fileOne)

 ADD_CUSTOM_COMMAND(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s
  COMMAND ${CMAKE_COMMAND}
     ARGS -E
          touch
          ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

 ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS targetFileOne 
 ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

 $ gmake
 Scanning dependencies of target targetFileOne
 [  0%] Generating fileOne
 [ 50%] Built target targetFileOne
 Scanning dependencies of target targetFileOneS
 gmake[2]: *** No rule to make target `targetFileOne', needed by 
 `CMakeFiles/targetFileOneS'.  Stop.
 gmake[1]: *** [CMakeFiles/targetFileOneS.dir/all] Error 2
 gmake: *** [all] Error 2

 So I am back to my problem that I cannot compile my project in parallel.
 The question is: How to implement mutexes in CMake scripts?

 Denis

 --- On Thu, 11/18/10, David Cole david.c...@kitware.com wrote:

 From: David Cole david.c...@kitware.com
 Subject: Re: [CMake] Problems with parallel builds
 To: Denis Scherbakov denis_scherba...@yahoo.com
 Cc: cmake@cmake.org
 Date: Thursday, November 18, 2010, 6:43 AM
 Try:
 ADD_CUSTOM_TARGET(MyHeaders ALL DEPENDS MyFile.hh)

 Without the ALL your target is not included in the set of
 targets
 built by a make or a make all -- without your target
 included in
 make there is nothing for the subsequent targets to
 depend on.
 Perhaps we should add a warning to add_dependencies if
 expressing a
 dependency on something not in all by default


 On Thu, Nov 18, 2010 at 9:33 AM, Denis Scherbakov
 denis_scherba...@yahoo.com
 wrote:
  Hi, David,
 
  I did as you suggested:
 
  ADD_CUSTOM_COMMAND(OUTPUT MyFile.hh ...)
  ADD_CUTSOM_TARGET(MyHeaders DEPENDS MyFile.hh)
 
  ADD_LIBRARY(MYLIB ${MYLIB_SRCS})
  ADD_DEPENDENCIES(MYLIB  MyHeaders)
 
  ADD_LIBRARY(MYLIBpic ${MYLIB_SRCS})
  ADD_DEPENDENCIES(MYLIBpic  MyHeaders)
 
  Didn't work. Target MyHeaders is build two times
 when I do gmake -j2
  I see two Generating MyFile.hh lines and MyFile.hh
 has duplicate lines.
 
  Denis
 
  David Cole wrote:
 
  The easiest way to make this work is to have a
 separate
  custom target
  that depends on the output of the custom command,
 and then
  to have the
  two libraries depend on that custom target with
  add_dependencies...
 
 
 
 
 






Instead of:
 ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS targetFileOne 
 ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

Try:
ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)
ADD_DEPENDENCIES(targetFileOneS targetFileOne)

And you cannot specify more than one target name to parallel make and
expect it to work. It only works if you do make or make
singleTarget.
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Alan W. Irwin

On 2010-11-18 07:18-0800 Denis Scherbakov wrote:


David,

Thank you for spending your time to resolve my problem.

Unfortunately you suggestion did not help.

Introduction of new custom targets in my case leads to the fact that
I have one custom target that depends on another custom target. I get:

gmake[3]: *** No rule to make target 'customTargetA', needed by 
'customTargetB'.  Stop.

And in this case it is not even a parallel build.

Now I remember that I already tried this custom-target trick about
a year ago and it failed with gmake error I specified above.

So CMake is not parallel build ready.
BTW, gmake -j4 targetA targetB also fails. You need to gmake -j4 targetA
and then gamake -j4 targetB to get correct results.


Denis:

I have been following this discussion with interest and assumed you
would quickly find the source of your parallel build issue.

I assure you cmake is parallel build ready, i.e., lots of
people including me use parallel builds with cmake with no problems
for quite complex builds. It is not completely trivial to set it up
right for a given complex project, but it can be done.

Since you are having problems with setting it up right for your
complex project, I suggest you try making the simplest example of your
issue: a generated one-line header and two simple libraries (each with
only a few lines of code) that depend upon it.  Then wrap that simple
example up in a tarball so others can verify the issue you are finding
(or make the fix to your simple example so that it works properly with
parallel builds).

The other big advantage of the simple example approach is that 99
times out of 100 (at least in my case) the simple example works fine
and it turns out the source of the problem is the implementation of
the logic of the simple example isn't done consistently in the complex
project (e.g., some third library you forgot about also depends on
your generated header) or there is some other CMake logic in
your complex project that needs changing to make your project
ready for parallel builds.

Alan
__
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__

Linux-powered Science
__
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake


Re: [CMake] Problems with parallel builds

2010-11-18 Thread Eric Noulard
2010/11/18 David Cole david.c...@kitware.com:
 On Thu, Nov 18, 2010 at 1:08 PM, Denis Scherbakov
 denis_scherba...@yahoo.com wrote:
 Here is a sample CMakeLists.txt to illustrate that two custom targets cannot 
 depend on each other:

 PROJECT(BUG C)

 CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

 ADD_CUSTOM_COMMAND(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/fileOne
  COMMAND ${CMAKE_COMMAND}
     ARGS -E
          touch
          ${CMAKE_CURRENT_BINARY_DIR}/fileOne)

 ADD_CUSTOM_TARGET(targetFileOne DEPENDS 
 ${CMAKE_CURRENT_BINARY_DIR}/fileOne)

 ADD_CUSTOM_COMMAND(
  OUTPUT  ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s
  COMMAND ${CMAKE_COMMAND}
     ARGS -E
          touch
          ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

 ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS targetFileOne 
 ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)
[...]


 Instead of:
 ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS targetFileOne 
 ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)

 Try:
 ADD_CUSTOM_TARGET(targetFileOneS ALL DEPENDS
 ${CMAKE_CURRENT_BINARY_DIR}/fileOne-s)
 ADD_DEPENDENCIES(targetFileOneS targetFileOne)

This solution works for me on Linux + CMake 2.8.1 and up.

-- 
Erk
Membre de l'April - « promouvoir et défendre le logiciel libre » -
http://www.april.org
___
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake