I am trying to use CUDA in MITK platform. The MITK platform that I am using is 2014 version which is not supporting CUDA; however, i found a reply which shows a solution but its not working for me either. According to the Cmake structure of MITK, if I set "*.cpp" files to CPP_FILES flag in files.cmake script, gcc compiles the source code, but for cuda there is no variable. Therefore, according to above link, I modified "mitkFunctionCreateModule.cmake"
if (IS_CUDA)
find_package(CUDA REQUIRED)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -std=c++11 )
#list(APPEND CUDA_NVCC_FLAGS "-arch=sm_20;-std=c++11;-O2;-DVERBOSE")
#SET(CUDA_PROPAGATE_HOST_FLAGS OFF)
message ("is_cuda == true")
cuda_add_library(${MODULE_TARGET} STATIC ${CUDA_FILES})
endif()
In files.cmake, I have added these lines:
find_package(CUDA)
set(CUDA_FILES
src/robot/cudafolder/testcuda.cu
src/robot/cudafolder/testcuda.h
)
set(IS_CUDA true)
MITK_CREATE_MODULE(my_module
DEPENDS MitkCore
PACKAGE_DEPENDS Qt5|Core
#ADDITIONAL_LIBS abc glew
)
The libmy_module.a is created in bin folder but I cannot link it to the main executable file !
PS: the biggest problem that I am face to is that I cannot use target_link_libraries
! For any reason that I dont know, its not possible to link this library to the main MITK exe file. Anyone in mitk expert who works in plugin module can help me in this matter?
Thanks
Finally I found a solution to add CUDA in the heart of MITK Plugin.
the solution is to add these lines at the end of files.cmake
find_package(CUDA)
set(CUDA_FILES
src/robot/cudafolder/testcuda.cu
src/robot/cudafolder/testcuda.h)
set(MyCudalib CudaTestLib)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -std=c++11 )
cuda_add_library( ${MyCudalib} SHARED ${CUDA_FILES})
Then from the same path in side CmakeLists.txt
add these lines
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${MyCudalib} ${CUDA_LIBRARIES} ${CUDA_nppi_LIBRARY})
And it works for me