[CMake] Cuda with CMake

James Bigler jamesbigler at gmail.com
Sat Jul 31 15:39:40 EDT 2010


On Thu, Jul 29, 2010 at 12:33 PM, Ryan Pavlik <rpavlik at iastate.edu> wrote:

>  On 7/29/10 10:10 AM, lokmane.abbas-turki wrote:
>
>>
>>
>> I am a beginner on creating Visual projects with CMake for Cuda
>> applications. I use the following CMakeLists
>>
>> cmake_minimum_required(VERSION 2.8)
>>
>> PROJECT(FermeHedge)
>>
>> #Searching CUDA
>> FIND_PACKAGE(CUDA)
>>
> OK, this line is good, but...
>
>  #Include the FindCUDA script
>> INCLUDE(FindCUDA)
>>
> This line duplicates the previous line poorly - you can remove it.
>
>
Correct.  This is if you had a local FindCUDA.cmake script, and should be
used alternatively to the find_package(CUDA) command not in addition to.


>  SET(SOURCES
>>         aleat_lin.cu
>>         init.cu
>>         io.cu
>>         main.cu
>>         tools.cu
>>         vars.cu
>>         aleat_lin.h
>>         init.h
>>         io.h
>>         timer.h
>>         tools.h
>>         types.h
>>         vars.h
>> )
>>
>>                    ADD_EXECUTABLE(FermeHedge ${SOURCES})
>>
>> and I have the following generation errors
>>
>> Configuring done CMake Error: CMake can not determine linker language for
>> target:FermeHedge
>> CMake Error: CMake can not determine linker language for target:FermeHedge
>> CMake Error: CMake can not determine linker language for target:FermeHedge
>> Generating done
>>  I think that I should set up some paths manually, but I don't know which
>> ones. Thanks for help
>>
>>  It doesn't look like you have a .c or .cpp main application - header
> files are added to project files but generally not compiled on their own.
> Thus, CMake doesn't know how to link any object files produced.
>
> If you want to create a CUDA executable, it looks like the
> find_package(CUDA) command defines some functions, including
> cuda_add_executable which is possibly what you want.  See the top of the
> FindCUDA.cmake file or the web docs under "Standard CMake Modules" for more
> info.
>
> Ryan
>

Correct.  You have to use cuda_add_executable instead of add_executable.
add_executable only knows about files that CMake is built to know about.
cuda_add_executable knows how to deal with the CUDA files.

I would suggest reading the documentation as Ryan suggests, and afterward if
you have further questions bring them up in the mailing list.

James
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100731/fa51fd9d/attachment.htm>


More information about the CMake mailing list