[ITK] [ITK-users] Create ITK Project with CUDA from CMake

jose alejandro matute flores jmatuteflores at gmail.com
Tue Mar 21 18:39:38 EDT 2017


Hi,

I use cuda as well, I have a different directory for my cuda parts of the
application.
What I do is create a static library and link it to the application.
It might not be the best way, but it's been working so far.


 -------------------cuda/CMakeLists.txt ------------------------

FIND_PACKAGE(CUDA REQUIRED)


set (CUDA_NVCC_FLAGS "-g -G -lineinfo" CACHE STRING "nvcc flags" FORCE)


SET (CUDA_VERBOSE_BUILD ON CACHE BOOL "nvcc verbose" FORCE)


SET(LIB_TYPE STATIC)    #set the lib type

CUDA_ADD_LIBRARY(cudaLibName ${LIB_TYPE} visual.h visual.cu )


--------------------------------------------------



and in the main project directory


------- CMakeLists.txt---------------------


find_package(CUDA REQUIRED)

add_subdirectory(cuda)


INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/cuda)

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/cuda/lib)

LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/cuda)

LINK_DIRECTORIES(${CMAKE_SOURCE_DIR}/cuda/lib)

cuda_add_executable(CUDAitk ${SOURCES}  )


ADD_DEPENDENCIES(CUDAitk cudaLibName)


target_link_libraries( CUDAitk  cudaLibName ....  )


---------------------------------------------


Best,
José

On Tue, Mar 21, 2017 at 6:49 PM, D'Isidoro Fabio <fisidoro at ethz.ch> wrote:

> Hallo,
>
>
>
> I have a .cu CUDA main code which makes use of itk to read and write
> images.
>
>
>
> How can I create a new ITK project with Cmake that include CUDA? I could
> not find any tutorial/description on it. Since I am not familiar with
> Cmake, I would need an understandable and detailed description.
>
>
>
> The most basic CmakeLists.txt I could find does not work:
>
>
>
> ------------------------------
>
> project(CUDAitk)
>
>
>
> find_package(ITK REQUIRED)
>
> include(${ITK_USE_FILE})
>
>
>
> find_package(CUDA REQUIRED)
>
>
>
> CUDA_INCLUDE_DIRECTORIES(${ITK_INCLUDE_DIRS})
>
>
>
> cuda_add_executable(CUDAitk CUDAitk.cu)
>
> target_link_libraries(CUDAitk ${ITK_LIBRARIES})
>
>
>
> ------------------------------
>
>
>
> The compling errors I get are like:
>
>
>
> error C2244: 'itk::FixedArray<TValue,VLength>::FixedArray': unable to
> match function definition to an existing declaration
>
>
>
> CMake Error at CUDAitk_generated_CUDAitk.cu.obj.Debug.cmake:267 (message):
>
>     Error generating file
>
>     C:/Users/Fabio/Documents/CUDAitk_cpp2/bin/CMakeFiles/
> CUDAitk.dir//Debug/CUDAitk_generated_CUDAitk.cu.obj
>
>
>
>
>
> Any help is highly appreciated.
>
>
>
> Thank you!
>
>
>
> Fabio
>
>
>
>
>
>
>
>
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/insight-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20170321/bb8b9d36/attachment-0001.html>
-------------- next part --------------
_____________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list