MantisBT - CMake
View Issue Details
0012313CMakeModulespublic2011-07-02 17:042011-07-06 16:08
Mourad 
James Bigler 
normalmajoralways
closednot fixable 
CMake 2.8.4 
 
0012313: SET_TARGET_PROPERTIES does not add DEFINE_SYMBOL to cuda files build rule
I am trying to build a shared cuda library with MSVC and CMake. I want to use a custom DEFINE_SYMBOL, but it doesn't work. When looking into the generated *.cu.obj.cmake file, i can see only the default DEFINE_SYMBOL (-Dmycudalib_EXPORTS).
* add a cuda library :
CUDA_ADD_LIBRARY(mycudalib SHARED file.cu)

* set a custom DEFINE_SYMBOL
SET_TARGET_PROPERTIES(mylib DEFINE_SYMBOL CUSTOM_DEFINE_SYMBOL)
No tags attached.
Issue History
2011-07-02 17:04MouradNew Issue
2011-07-04 09:02Brad KingAssigned To => James Bigler
2011-07-04 09:02Brad KingStatusnew => assigned
2011-07-04 09:03Brad KingNote Added: 0027005
2011-07-04 10:04MouradNote Added: 0027006
2011-07-05 12:25James BiglerNote Added: 0027009
2011-07-06 15:32MouradNote Added: 0027014
2011-07-06 16:08James BiglerNote Added: 0027015
2011-07-06 16:08James BiglerStatusassigned => closed
2011-07-06 16:08James BiglerResolutionopen => not fixable

Notes
(0027005)
Brad King   
2011-07-04 09:03   
As a sanity check on the steps to reproduce, you wrote:

  CUDA_ADD_LIBRARY(mycudalib SHARED file.cu)
  SET_TARGET_PROPERTIES(mylib DEFINE_SYMBOL CUSTOM_DEFINE_SYMBOL)

but the target names do not match: "mycudalib" v. "mylib". I assume you meant them to match?
(0027006)
Mourad   
2011-07-04 10:04   
Yes you are right, the target names are meant to match.

CUDA_ADD_LIBRARY(mycudalib SHARED file.cu)
SET_TARGET_PROPERTIES(mycudalib DEFINE_SYMBOL CUSTOM_DEFINE_SYMBOL)
(0027009)
James Bigler   
2011-07-05 12:25   
This will never work with the current implementation.

1. FindCUDA doesn't support setting properties after calls to CUDA_ADD_*, because all the build commands are generated at the call site (configure time) of CUDA_ADD_* and not later (generation time).
2. As far as I know target properties can't be added on targets that don't exist yet, so this turns into a chicken and egg problem. If CMake supported generate time configure files, this might be able to be supported.

I would suggest you set the define as a flag.
CUDA_ADD_LIBRARY(mylib SHARED file.cu OPTIONS -DCUSTOM_DEFINE_SYMBOL)

Please let me know if this work around won't work for you.
(0027014)
Mourad   
2011-07-06 15:32   
Thanks for looking into this. Yes the work around you suggested does work for me.
(0027015)
James Bigler   
2011-07-06 16:08   
Thanks for replying Mourad.