Issue #1532: Incompatible config options, /MP vs /Gm for MSVC in DEBUG (#1533)
* Issue #1532: Incompatible config options, /MP vs /Gm for MSVC in DEBUG
diff --git a/tools/pybind11Tools.cmake b/tools/pybind11Tools.cmake
index ba17d7f..ab8bf62 100644
--- a/tools/pybind11Tools.cmake
+++ b/tools/pybind11Tools.cmake
@@ -209,15 +209,15 @@
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 $<$<NOT:$<CONFIG:Debug>>:/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 $<$<COMPILE_LANGUAGE:CXX>:${msvc_extra_options}>)
+ target_compile_options(${target_name} PRIVATE $<$<NOT:$<CONFIG:Debug>>:$<$<COMPILE_LANGUAGE:CXX>:/MP>>)
endif()
endif()
endfunction()