Skip to content

[BUG]: CMake bigobj option incompatible with nvcc #3883

@LXLWDGY

Description

@LXLWDGY

Required prerequisites

Problem description

The cmake compile options for pybind11 currently adds a /bigobj option if MSVC is used, as can be seen here:

PROPERTY INTERFACE_COMPILE_OPTIONS /bigobj)

This is problematic if the language is in anything other than C++, which in my case was CUDA. The nvcc compiler does not recognize /bigobj (or at least I think this is what happens) and therefore raises an error:

[Nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified]

There is a very similar issue raised here, which details a bug concerning /MP:
#1532 (comment)

There are a lot of similar bugs if you care to google, and the consensus (whenever there is one) seems to be that /MP and /bigobj are the culprits. I personally have solved this problem by simply changing the line to, but I'm not certain whether this is the best fix:
PROPERTY INTERFACE_COMPILE_OPTIONS $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/bigobj>>)

Reproducible example code

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions