diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake index ba17d7f25..ab8bf6270 100644 --- a/tools/pybind11Tools.cmake +++ b/tools/pybind11Tools.cmake @@ -209,15 +209,15 @@ function(pybind11_add_module target_name) if(MSVC) # /MP enables multithreaded builds (relevant when there are many files), /bigobj is # needed for bigger binding projects due to the limit to 64k addressable sections - set(msvc_extra_options /MP /bigobj) + target_compile_options(${target_name} PRIVATE /bigobj) if(CMAKE_VERSION VERSION_LESS 3.11) - target_compile_options(${target_name} PRIVATE ${msvc_extra_options}) + target_compile_options(${target_name} PRIVATE $<$>:/MP>) else() # Only set these options for C++ files. This is important so that, for # instance, projects that include other types of source files like CUDA # .cu files don't get these options propagated to nvcc since that would # cause the build to fail. - target_compile_options(${target_name} PRIVATE $<$:${msvc_extra_options}>) + target_compile_options(${target_name} PRIVATE $<$>:$<$:/MP>>) endif() endif() endfunction()