Problem using CMake to build a CPP+CUDA app [cross-post from Nsight Eclipse forum] (Solved)

Hello,

I have posted this query in the forum for Nsight Eclipse Edition, but thought I would re-post it again here, in case someone viewing this forum has run across this problem before.

I have a project in Nsight Eclipse Edition on Ubuntu 16.04 targeted towards the DRIVE PX 2 AutoChauffeur platform. The project contains source code written in C/C++/OpenCV, and I am using CMakeLists.txt to configure and build. A redacted version of my CMakeLists.txt is shown below.

# Copyright (c) 2018

cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(MYPROJECT C CXX)

set(SOURCES 
source1.cpp 
source1.h 
source2.cpp 
source2.h 
source3.cpp 
source3.h)

set(CMAKE_VERBOSE_MAKEFILE TRUE)

add_executable( MYPROJECT_BIN ${SOURCES})

include_directories("/home/user/opencv-3.4.0/build-target_new/install_new/include")

target_link_libraries(
MYPROJECT 
PUBLIC 
/home/user/drive-t186ref-cuda/target/var/cuda-repo-9-0-local/usr/local/cuda-9.0/lib64/libcudart.so.9.0
/home/user/NVIDIA/Drive/5050bL_SDK/DriveSDK/toolchains/tegra-4.9-nv/usr/sysroot/lib/libpthread.so.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppc.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppial.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppicc.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppicom.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppidei.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppif.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppig.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppim.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppist.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppisu.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnppitc.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libnpps.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcublas.so.9.0
/usr/local/cuda-9.0/targets/aarch64-linux/lib/libcufft.so.9.0
/home/user/opencv-3.4.0/build-target-shared/install/lib/libopencv_core.so.3.4.0
/home/user/opencv-3.4.0/build-target-shared/install/lib/libopencv_highgui.so.3.4.0
/home/user/opencv-3.4.0/build-target-shared/install/lib/libopencv_imgcodecs.so.3.4.0
/home/user/opencv-3.4.0/build-target-shared/install/lib/libopencv_imgproc.so.3.4.0
/home/user/opencv-3.4.0/build-target-shared/install/lib/libopencv_cudev.so.3.4.0
/home/user/opencv-3.4.0/build-target-shared/install/lib/libopencv_videoio.so.3.4.0
)
    • I have some CUDA kernels in development using the NPP library; hence the NPP related inclusions.

I followed the blog https://devblogs.nvidia.com/drivepx-application-development-using-nsight-eclipse-edition/ to additionally configure the build symbols and set up the toolchain.

This all worked fine initially for the C/C++/OpenCV code. But recently, I included a custom CUDA kernel and some associated CUDA code in one of the .CPP files, and changed the extension of the source file to .CU. I included the .CU file in the list of sources in the CMakeLists.txt, and then tried to build the project again. But the build does not appear to invoke the NVCC compiler for the .CU file. In fact, the .CU file is completely ignored, and that results in multiple build errors.

I do not have enough experience on CMAKE to figure out how I can resolve this issue. Can anyone help me out?

Thank you.

Dear sagar,
Can you please check /usr/local/driveworks-1.2/samples/src/image/image_common/CMakeLists.txt to add .cu files into project?

Dear SivaRamaKrishna,

We are currently using DriveWorks 0.6, and do not wish to change that.
Is it possible to refer to the said CMakeLists.txt file in any other way?

Thank you.

Dear sagar,
You can check the same sample’s CMakeLists.txt in DW 0.6 to add .cu files into project