[CMake] Setting compile defs with: Cuda, add_subdirectory, and set_target_properties (COMPILE_DEFINITIONS)

James Bigler jamesbigler at gmail.com
Tue Aug 17 11:21:42 EDT 2010


On Tue, Aug 17, 2010 at 9:08 AM, Brian Davis <bitminer at gmail.com> wrote:

> I am and it is working.  It is not clear to me still why it would be a
> problem with parallel builds due to the target object naming convention you
> have used as stated in:
>
> --snip --
>
> Yup, I just build file names by appending/prepending things:
> <target>_generated_<filename>.<target_type>.depend.tmp.  The .depend file is
> the dependency file used to track dependencies, and the tmp version is what
> nvcc generates.  I then use a copy_if_different command, so that the
> dependency file only gets its timestamp updated if it actually changes.  GCC
> -M only writes to the dependency file if it changes, but nvcc -M always
> write to it, so I have to emulate this behavior myself.
>    --end snip--
>
>
The problem is the existence of multiple rules that create the same output
file in multiple projects.  This is because when you attach a build rule to
a file, the build rule follows the file across projects (at least within the
same source directory).

project1
  -- myfile.cu: had rule to build project1_myfile.cu.obj from myfile.cu

project2
  CMake Rules
    -- cmake_build_..._myfile.rule: has rule to build project2_myfile.cu.obj
from myfile.cu
  -- myfile.cu: has rule to build project1_myfile.cu.obj from myfile.cu

There are two rules to build project1_myfile.cu.obj.  If you compiled
project1 and project2 at the same time, there is a chance that the rules to
generate project1_myfile.cu.obj will be run at the same time, and two
processes trying to write to the same file causes race conditions.  When the
CUDA_ATTACH flag is turned off this doesn't happen, and life is good for you
again. :)



>
> Thanks again for the help.
>
>
You're welcome!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100817/405148aa/attachment.htm>


More information about the CMake mailing list