[CMake] [FindCUDA] CUDA_COMPILE_PTX

James Bigler jamesbigler at gmail.com
Wed Feb 17 18:16:39 EST 2010


You need to add ${ptxfiles} to your add_executable command, so that it
contains both the source and generated files.

For makefile targets you need to establish a dependency between the target
(cuda_core_test) and your ptx files.  This is done by putting the generated
files into the target.  For VS it is backward, and you generally only need
to add the source files to the project (provided there is a MAIN_DEPENDENCY
set on the file - which it is for FindCUDA by default).

James

On Wed, Feb 17, 2010 at 12:37 PM, Denis Taniguchi <taniguchi at tpn.usp.br>wrote:

> Hi all,
>
> I was trying to use CUDA_COMPILE_PTX to make nvcc compile *.cu files
> to .ptx files but with no success.
> Running make just compile my regular .cpp files and does nothing to .cu
> files. I want the ptx files to use them with CUDA driver API.
> I checked in the trunk SVN repository of FindCUDA but the line for
> CUDA_COMPILE_PTX was commented out in the example.
> Regards,
>
> Denis
>
> #####################################################################
>
> # habilitar o módulo FindBoost
> find_package (Boost 1.42.0 COMPONENTS thread)
> # habilitar o módulo FindCUDA
> find_package (CUDA)
>
> file (GLOB_RECURSE sources *.cpp)
> file (GLOB_RECURSE cufiles *.cu)
> cuda_compile_ptx (ptxfiles cufiles)
> add_executable (cuda_core_test ${sources})
>
> # para poder usar variadic template parameters
> set_target_properties (cuda_core_test PROPERTIES COMPILE_FLAGS -std=c
> ++0x)
> # gcc version < 4.4 não possuem o header initilizer_list
> add_definitions (-DBOOST_NO_0X_HDR_INITIALIZER_LIST)
>
> include_directories (${CUDA_TOOLKIT_INCLUDE})
> target_link_libraries (cuda_core_test ${CUDA_CUDA_LIBRARY}
> ${Boost_LIBRARIES})
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20100217/aba7b2f1/attachment-0001.htm>


More information about the CMake mailing list