1

Building a CUDA 8.0 project with cuFFT callbacks requires using the statically linked cuFFT library and compile the code as relocatable device code using (-dc compiler option). I've been unable to make this happen with CMake v3.7.0 using CUFFT_STATIC_LIBRARY, etc.. Anyone been able to build such a project with CMake?

Relevant expressions in my project CMakeLists.txt for the dynamically linked cuFFT library:

find_package(CUDA REQUIRED)
list(APPEND CUDA_DEV_LIBRARIES
            ${CUDA_cufft_LIBRARY})

set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --std=c++11")

cuda_add_executable(${PROJECT_NAME} ${CPP_SRCS})

link_directories(${CUDA_LIBRARY_DIRS})
target_link_libraries(${PROJECT_NAME} ${CUDA_LIBRARIES} ${CUDA_DEV_LIBRARIES})
  • 2
    What exactly makes you unable to build it. Do you get errors or something? – Ivan Aksamentov - Drop Nov 16 '16 at 19:25
  • Tried a lot of different things, got a lot of different errors during the build. A common one was that nvcc complained about the `--std=c++11` flag, but it's needed for compilation. I'm hoping that someone can cut & paste a working CMakeLists.txt. – Andreas Yankopolus Nov 17 '16 at 13:58
  • I've figured out the `c++11` part. Usually I won't add this option since cmake will add it automatically. And your manually adding option will conflict with the cmake one. However, the static linking is troublesome. Now I guess maybe it has to run cmake `COMMAND` from scratch... – halfelf Nov 18 '16 at 05:09
  • 1
    In general, you should prefer to let CMake sort out what flags to use to enable C++11 rather than modifying `CMAKE_CXX_FLAGS`, etc. directly. You do this with the `CMAKE_CXX_STANDARD`, `CMAKE_CXX_STANDARD_REQUIRED` and `CMAKE_CXX_EXTENSIONS` variables. For a full discussion of this topic, see [this article](https://crascit.com/2015/03/28/enabling-cxx11-in-cmake/). It's possible though that this might not work reliably for some cross-compiling arrangements, so give it a try and see if it has been fully implemented for nvcc. – Craig Scott Nov 18 '16 at 22:41
  • Tried following the directions in the linked article and was rewarded with: `error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.` This was also after adding `set(CUDA_PROPAGATE_HOST_FLAGS ON)`. I'm digging around to see if there's a solution beyond manually adding the c++11 compiler flag as in my sample code. – Andreas Yankopolus Nov 21 '16 at 15:18
  • 1
    New documentation changes due for CMake 3.8.0 add target properties for CUDA_STANDARD and friends. Merge request for the docs changes [here](https://gitlab.kitware.com/cmake/cmake/merge_requests/319), but not sure if the target properties exist already and can be used with earlier versions. There's at least [one other merge request](https://gitlab.kitware.com/cmake/cmake/merge_requests/308) which implements related functionality for the new properties which is also due for 3.8.0. – Craig Scott Dec 31 '16 at 02:57

0 Answers0