<div dir="ltr">Compiling C++ code with CUDA compiler practically means only to implicitly include a bunch of CUDA-specific headers like cuda_runtime_api.h. Other than that, it's the same as compiling with the host C++ compiler. Thus, you can get the desired behavior by explicitly including those headers in case of C++-compilation and letting CMake include_directories to know where to search for them.<div><br></div><div>Kind regards,</div><div>- Dmitry.</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">вт, 2 июл. 2019 г. в 20:19, Kai Germaschewski <<a href="mailto:kai.germaschewski@gmail.com">kai.germaschewski@gmail.com</a>>:<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">For background, a bunch of projects help writing portable C++ code that can be compiled into CUDA device code as one option, e.g. hemi, kokkos, RAJA (<a href="https://devblogs.nvidia.com/simple-portable-parallel-c-hemi-2/" target="_blank">https://devblogs.nvidia.com/simple-portable-parallel-c-hemi-2/</a>). As a consequence, if available those source files need to be compiled with the CUDA compiler, but with the regular C++ compiler otherwise.<div><br></div><div>I'm wondering whether there is a clean way to support this in a cmake build. Renaming my source files to `.cu` is bad if I'm on the system without CUDA. I figured out that I can set the LANGUAGE property on a given .cpp/.cxx source file to CUDA to have it compiled with CMAKE_CUDA_COMPILER, but that's quite a hassle to do for every source file. Kokkos instead creates a `nvcc_wrapper` script which one is supposed to use as CMAKE_CXX_COMPILER, but that definitely seems like a kludge to me (and giving me troubles).</div><div><br></div><div>Things would probably be much better for me if there was a way to change the default language for .cxx / .cpp extensions. Is there a way to do this?</div><div><br></div><div>--Kai</div><div><br><div><br></div><div><br></div></div></div>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div>