diff --git a/CMakeLists.txt b/CMakeLists.txt index 31ac08eb8ed..8904ad153f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -271,7 +271,15 @@ if (MSVC) # /bigobj increases number of sections in .obj file, which is needed to link # against libraries in Python 2.7 under Windows - set(${flag_var} "${${flag_var}} /MP /bigobj") + # For Visual Studio generators, if /MP is not added, then we may need + # to add /MP to the flags. + # For other generators like ninja, we don't need to add /MP because it is + # already handled by the generator itself. + if(CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT ${flag_var} MATCHES "/MP") + set(${flag_var} "${${flag_var}} /MP /bigobj") + else() + set(${flag_var} "${${flag_var}} /bigobj") + endif() endforeach(flag_var) foreach(flag_var diff --git a/tools/setup_helpers/cmake.py b/tools/setup_helpers/cmake.py index b4e3fe662e0..1708566760a 100644 --- a/tools/setup_helpers/cmake.py +++ b/tools/setup_helpers/cmake.py @@ -335,7 +335,7 @@ class CMake: # minimum, which provides a '-j' option: build_args += ['-j', max_jobs] # would be sufficient by then. if IS_WINDOWS and not USE_NINJA: # We are likely using msbuild here - build_args += ['--', '/maxcpucount:{}'.format(max_jobs)] + build_args += ['--', '/p:CL_MPCount={}'.format(max_jobs)] else: build_args += ['--', '-j', max_jobs] self.run(build_args, my_env)