[CMake] CMake CUDA 3.8+/9 support as a first class language with out Visual Studio Support... err what?

Robert Maynard robert.maynard at kitware.com
Mon Jul 31 15:35:56 EDT 2017


My responses are inline.

On Sat, Jul 29, 2017 at 7:00 PM, Brian J. Davis <bitminer at gmail.com> wrote:
> @Robert
>
> I created a fresh simple cmake project in 3.9.  This appeared to find CUDA
> 8.0 successfully so it may have something do with my other project settings
> that I am trying to get to work with 3.9, VS13, CUDA 7.5/8.0.
>
> Using:
>
> message( CUDACXX = ${CUDACXX})
> message( CMAKE_CUDA_COMPILER = ${CMAKE_CUDA_COMPILER})
>
>
> Reports
>
> CUDACXX=
> CMAKE_CUDA_COMPILER=C:/Program Files/NVIDIA GPU Computing
> Toolkit/CUDA/v8.0/bin/nvcc.exe
> Configuring done
> Generating done
>
> The question was at setting the CUDA version say 7.5 or 8.0.
>
> I search doc for CUDACXX and CMAKE_CUDA_COMPILER with no hits.  Is this
> stuff documented anywhere.

Unfortunately the environment variables are not documented anywhere
and this is a known issue
that I hope to have fixed in CMake 3.10.

The CMAKE_CUDA_COMPILER falls under the the CMAKE_<LANG>_COMPILER documentation
now with the new CUDA support (
https://cmake.org/cmake/help/v3.8/variable/CMAKE_LANG_COMPILER.html ).


>
> Do I really need to say set:
>
> CMAKE_CUDA_COMPILER=C:/Program Files/NVIDIA GPU Computing
> Toolkit/CUDA/v7.5/bin/nvcc.exe
>
> To get CMake to compile for 7.5?  I mean:
>
> find_package(CUDA 7.5)
>
> you could agree is/was much simpler.  I am becoming frustrated and confused
> by these changes.

It might be possible in the future to provide other hint controls to
tell CMake which
version of CUDA you would like to use before the project /
enable_language call. This
would be something that is best addressed on the cmake developer list or as
a gitlab issue ( https://gitlab.kitware.com/cmake/cmake/issues )

>
> I can't even get a simple CUDA app to run using FindCUDA (will compile) or
> compile using v3.9 and new project( CXX CUDA).
>
> Your example at:
>
> https://cmake.org/cmake/help/latest/manual/cmake-compile-features.7.html
>
>
> Used:
>
> add_executable(CudaConsumeCompileFeatures main.cu)
>
> Is is required now that main.cpp be a .cu file now?  I wouldn't think so,
> but I am so lost in the woods on this that I am not sure of anything
> anymore.

So with the new CUDA support you can mix C/C++/CUDA sources together
inside a single library or executable. This example was only using CUDA
in the executable to reduce the complexity of the test.




>
> How do I get all the toolkit and sdk include and lib dir variables now as
> FindCUDA provided?

The toolkit include directory can be found by querying
CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
As far as CUDA SDK libraries those can simply used with target_link_libraries
as the SDK library path is considered to be an implicit link directory, and will
always be on the link line. This is actually the same for the CUDA sdk include
directory ( it will be placed on the include line when building ).

>
> I am so curfuffled by these changes.

These changes are needed to allow targets using CUDA to properly work with
'Modern' CMake (https://cmake.org/cmake/help/v3.8/manual/cmake-buildsystem.7.html#build-specification-and-usage-requirements).
Without these changes usage requirements and CUDA would never work together.

>
> Can I get the CMake doc in one (1) html page again... those were the good
> old days when scanning back and forth I would stumble on some good bits ...
> not that I can seemly find the doc for the new CUDA changes.  This reminds
> me of the days when I could only get doc on things like ExternalProject_Add
> at the command prompt.
>
>
>
>
>
>
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list