<div class="gmail_quote">On Mon, Aug 16, 2010 at 12:21 PM, Brian Davis <span dir="ltr">&lt;<a href="mailto:bitminer@gmail.com">bitminer@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>From my current research into this problem it looks like the issue can be traced to  these lines in FindCuda.cmake<br><br>--snip--<br>  # Get the list of definitions from the directory property<br>  get_directory_property(CUDA_NVCC_DEFINITIONS COMPILE_DEFINITIONS)<br>


message( &quot;CUDA_NVCC_DEFINITIONS = ${CUDA_NVCC_DEFINITIONS}&quot; )<br><br>  if(CUDA_NVCC_DEFINITIONS)<br>    foreach(_definition ${CUDA_NVCC_DEFINITIONS})<br>      list(APPEND nvcc_flags &quot;-D${_definition}&quot;)<br>


    endforeach()<br>  endif()<br>message( &quot;nvcc_flags = ${nvcc_flags}&quot; )<br>--end snip--<br><br>output from cmake as a result of added message line in Find.Cuda.<br><br>-- snip --<br>CUDA_NVCC_DEFINITIONS = 
gpuReconPlugin_EXPORTS=yes;GPU_RECON=yes;CUDADeviceProperties_DLLExport=yes;GPU_RECON=yes;CUDADeviceProperties_DLLExport=yes;CPU_RECON=yes<br>
nvcc_flags = 
-m64;-DgpuReconPlugin_EXPORTS=yes;-DGPU_RECON=yes;-DCUDADeviceProperties_DLLExport=yes;-DGPU_RECON=yes;-DCUDADeviceProperties_DLLExport=yes;-DCPU_RECON=yes<br>
-- end snip --<br><br>note the use of get_directory property.  Have I mentioned to anyone lately why I can&#39;t understand CMake&#39;s (poor)  design choice in correlating directory structure to target build specification. It would appear to me from this (if unmodified) that I must create a new directory in order to get CMake to build 2 dlls in the same directory based on the same source using diffrent compiler defined.   I have reached a state of boondogglement.<br>


</blockquote></div><br>This is how CMake works.  ADD_DEFINITIONS is a directory property and not a target property.  If you wish to have per target definitions, there are other ways to accomplish this:<br><br>    set(my_nvcc_flags)<br>

    foreach( DEFINE_STR ${ARG_DEFINES} )<br>
        message( &quot;DEFINE_STR = ${DEFINE_STR}&quot; )<br>        list(APPEND my_nvcc_flags -D${DEFINE_STR} )<br>    endforeach()<br><br>    if(DEFINED ARG_CU_SOURCES )<br>        message( &quot;ARG_CU_SOURCES is defined as = ${ARG_CU_SOURCES}&quot; )<br>


        CUDA_ADD_LIBRARY( ${LIB_NAME} SHARED ${MATLAB_CUDA_FILES} <span style="background-color: rgb(255, 255, 102);">OPTIONS ${my_nvcc_flags}</span> )<br>    else()<br>        message( &quot;ARG_CU_SOURCES is not defined&quot; )<br>

       ADD_LIBRARY( ${LIB_NAME} SHARED ${MATLAB_CUDA_FILES} )<br>    endif()<br>
<br>And don&#39;t forget to add the definitions to the target, since you are no longer using add_definitions.<br><br>    if( DEFINED ARG_DEFINES )<br>    SET_TARGET_PROPERTIES( ${LIB_NAME} PROPERTIES <br>
        PREFIX &quot;&quot; <br>#        COMPILE_DEFINITIONS<span style="background-color: rgb(255, 255, 102);"> ${ARG_DEFINES}</span> )<br>#        COMPILE_DEFINITIONS MY_DEFINE=DEFINE_THIS_GOOP<br>        COMPILE_FLAGS -DMY_DEFINE=DEFINE_THIS_GOOP<br>

        )<br>    endif()<br>
<br>FindCUDA.cmake can&#39;t use the target properties, because target properties can be set anytime, and the FindCUDA.cmake script needs the properties at the time cuda_add_libraries is called.  This is because FindCUDA.cmake generates build scripts at configure time and not at generate time.<br>

<br>James<br>