Closed
Description
Issue description
Compilation fails when using CMake and pybind11_add_module for project containing CUDA code. The -flto flag is passed to NVCC and causes the following output:
nvcc fatal : Unknown option 'flto'
Reproducible example code
In CMakeLists.txt:
cmake_minimum_required(VERSION 3.14)
project(projectname LANGUAGES CXX CUDA)
find_package(pybind11 REQUIRED)
pybind11_add_module(modulename src/cpp_source.cpp src/cuda_source.cu)
Possible solution
In pybind11/tools/pybind11Tools.cmake
, line 104:
-use $<$<COMPILE_LANGUAGE:CXX>:
to set the flag only for GCC
-pass it to nvcc as -Xcompiler=-flto
Metadata
Metadata
Assignees
Labels
No labels