Hi,
I’m currently trying to compile my CUDA project using cmake but I’m running into some issues. Specifically, on the last step of the makefile when the executable is created, for some reason nothing gets passed to g++. Here is the error in particular:
Last bit of make output
[ 80%] Building CXX object CMakeFiles/stockModel.dir/main.o
/usr/bin/c++ -I/usr/local/cuda-8.0/include -o CMakeFiles/stockModel.dir/main.o -c /home/ubuntu/cmaketest/main.cpp
[100%] Linking CXX executable stockModel
/usr/local/bin/cmake -E cmake_link_script CMakeFiles/stockModel.dir/link.txt --verbose=1
<b>/usr/bin/c++</b>
c++: fatal error: no input files
compilation terminated.
CMakeFiles/stockModel.dir/build.make:683: recipe for target 'stockModel' failed
make[2]: *** [stockModel] Error 1
make[2]: Leaving directory '/home/ubuntu/cmaketest'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/stockModel.dir/all' failed
make[1]: *** [CMakeFiles/stockModel.dir/all] Error 2
make[1]: Leaving directory '/home/ubuntu/cmaketest'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
As seen above, nothing gets passed to the g++ call, not even the name of the executable I’m trying to create. Here is the cmake file I’m using.
CMakeLists.txt
project(stockModel)
find_package(CUDA)
set(GPU_ACCELERATED ${CUDA_FOUND})
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -std=c++11; -lcurand;"
)
set_source_files_properties(callModels.cpp PROPERTIES
CUDA_SOURCE_PROPERTY_FORMAT OBJ)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}
-L/usr/local/cuda/lib64")
cuda_add_executable(stockModel main.cpp callModels.cpp callModels.h debugCFP.cu debugCFP.h prng.cu prng.h)
I suspect this has something to do with my modifying of the source file properties of callModels, however this is the only way I’ve found that allows me to compile the source file through nvcc instead of g++ (it supports a GPU accelerated mode, or just regular).
Any ideas what I’m doing wrong in my cmake file? For reference, all source and header files are in the same directory as CMakeLists.txt
Thanks in advance for any help.