<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Hi Reza,<br> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">find_package(CUDA REQUIRED)</span></font><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">if (CUDA_FOUND)</span></font></div><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">    message("CUDA found!")</span></font></div><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">else()</span></font></div><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">    message("CUDA not found, doing something alternatively")</span></font></div><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">endif()</span></font></div></div></div></blockquote><div><br></div><div>The if(CUDA_FOUND) is redundant since the REQUIRED argument to find_package will generate a fatal error if not found.  If you want to be able to have two different configurations, one found and one not found, then just remove the REQUIRED from find_package(CUDA).<br></div><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px"></span></font></div><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}</span></font></div></div></div></blockquote><div><br></div><div>Rather than explicitly force the CXX flags, there's more compiler agnostic ways to address this:<br> <br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px"> -std=c++11</span></font></div></div></div></blockquote><div><br></div><div>instead of forcing the flag, let CMake do the work for you.  Just set the CXX_STANDARD=11 property on the resulting target and CMake will know how to set the correct flag.<br><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px"> -D_FORCE_INLINES</span></font></div></div></div></blockquote><div><br></div><div> Use add_definitions(<font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">-D_FORCE_INLINES).  The end effect is the same but it does a better job of propagating target usage requirements under the hood.<br></span></font></div><div> </div><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px"></span></font></div><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px">CUDA_ADD_EXECUTABLE(Test <a href="http://source.cu/" target="_blank">source.cu</a>)</span></font></div></div></div></blockquote><div><br></div><div>Ideally you should keep the host and device code seperate.  That way the CUDA compiler is only used for actual CUDA code and your host compiler deals with the rest. <br></div><br><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><font color="#242729" face="arial, helvetica, sans-serif"><span style="font-size:15px;line-height:19.5px"></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="color:rgb(36,39,41);font-size:15px;line-height:19.5px">I am using CUDA 7.5, VTK 7.0.0 and CMake 3.6.0. Here is the <a href="http://source.cu/" target="_blank">source.cu</a>. It is basically combination of VTK Hello World example (Rendering a Cylinder) and vectorAdd.cu in CUDA samples and both are working separately.</span><font color="#242729"><span style="font-size:15px;line-height:19.5px"><br></span></font></font></div></div></div></blockquote><div><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><font face="arial, helvetica, sans-serif"><font color="#242729"><span style="font-size:15px;line-height:19.5px"></span></font></font></div><div><div><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:15px;clear:both;color:rgb(36,39,41);line-height:19.5px"><font face="arial, helvetica, sans-serif"><font face="arial, helvetica, sans-serif">What are my mistakes that VS12 cannot find includes of VTK in my codes</font></font></p></div></div></div></div></blockquote><div>You're missing a call to CUDA_INCLUDE_DIRECTORIES to pass them to the separate CUDA compiler<br> <br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div style="font-size:12.8px"><div><div><p style="margin:0px 0px 1em;padding:0px;border:0px none;font-size:15px;clear:both;color:rgb(36,39,41);line-height:19.5px"><font face="arial, helvetica, sans-serif">Generally, how do we write a CMake code when we want to combine CUDA and VTK?</font></p></div></div></div></div></blockquote>Putting it all together, we get:<br></div><br><span style="font-family:monospace,monospace">cmake_minimum_required(VERSION 3.3)<br>project(Test)<br><br>find_package(VTK REQUIRED)<br>include(${VTK_USE_FILE})<br><br>find_package(CUDA REQUIRED)<br><br>add_definitions(-D_FORCE_INLINES)<br><br>set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --gpu-architecture sm_20)<br><br>// The following is ONLY necessary if your CDA code is actually including VTK<br>CUDA_INCLUDE_DIRECTORIES(${VTK_INCLUDE_DIRS})<br><br>CUDA_ADD_EXECUTABLE(Test cylinder.cxx vectorAdd.cu)<br>target_link_libraries(Test ${VTK_LIBRARIES})<br>set_target_properties(Test PROPERTIES CXX_STANDARD 11)</span><br><br></div><div class="gmail_extra">Hope that helps,<br></div><div class="gmail_extra">- Chuck<br></div></div>