mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-21 06:10:16 +08:00
VS: Add property to turn off Visual Studio compile batching
Resolves: #23179
This commit is contained in:
@@ -381,6 +381,7 @@ syn keyword cmakeProperty contained
|
||||
\ VS_JUST_MY_CODE_DEBUGGING
|
||||
\ VS_KEYWORD
|
||||
\ VS_MOBILE_EXTENSIONS_VERSION
|
||||
\ VS_NO_COMPILE_BATCHING
|
||||
\ VS_NO_SOLUTION_DEPLOY
|
||||
\ VS_PACKAGE_REFERENCES
|
||||
\ VS_PLATFORM_TOOLSET
|
||||
|
@@ -402,6 +402,7 @@ Properties on Targets
|
||||
/prop_tgt/VS_JUST_MY_CODE_DEBUGGING
|
||||
/prop_tgt/VS_KEYWORD
|
||||
/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION
|
||||
/prop_tgt/VS_NO_COMPILE_BATCHING
|
||||
/prop_tgt/VS_NO_SOLUTION_DEPLOY
|
||||
/prop_tgt/VS_PACKAGE_REFERENCES
|
||||
/prop_tgt/VS_PLATFORM_TOOLSET
|
||||
|
21
Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst
Normal file
21
Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst
Normal file
@@ -0,0 +1,21 @@
|
||||
VS_NO_COMPILE_BATCHING
|
||||
----------------------
|
||||
|
||||
.. versionadded:: 3.24
|
||||
|
||||
Turn off compile batching for the target. Usually MSBuild calls the compiler
|
||||
with multiple c/cpp files and compiler starts subprocesses for each file to
|
||||
make the build parallel. If you want compiler to be invoked with one file at
|
||||
a time set VS_NO_COMPILE_BATCHING to ON. If this flag is set MSBuild will call
|
||||
compiler with one c/cpp file at a time. Useful when you want to use tool that
|
||||
replaces the compiler, for example some build caching tool.
|
||||
|
||||
Example
|
||||
^^^^^^^
|
||||
|
||||
This shows setting the variable for the target foo.
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
add_library(foo SHARED foo.cpp)
|
||||
set_property(TARGET foo PROPERTY VS_NO_COMPILE_BATCHING ON)
|
6
Help/release/dev/vs_buildcache_support.rst
Normal file
6
Help/release/dev/vs_buildcache_support.rst
Normal file
@@ -0,0 +1,6 @@
|
||||
vs_buildcache_support
|
||||
---------------------
|
||||
|
||||
* The :prop_tgt:`VS_NO_COMPILE_BATCHING` target property was added to
|
||||
tell :ref:`Visual Studio Generators` whether to disable compiler parallelism
|
||||
and call the compiler with one c/cpp file at a time.
|
@@ -3298,7 +3298,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
|
||||
} else if (this->MSTools) {
|
||||
cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
|
||||
const char* toolset = this->GlobalGenerator->GetPlatformToolset();
|
||||
if (toolset && clangToolset.find(toolset)) {
|
||||
cmValue noCompileBatching =
|
||||
this->GeneratorTarget->GetProperty("VS_NO_COMPILE_BATCHING");
|
||||
if (noCompileBatching.IsOn() || (toolset && clangToolset.find(toolset))) {
|
||||
e2.Element("ObjectFileName", "$(IntDir)%(filename).obj");
|
||||
} else {
|
||||
e2.Element("ObjectFileName", "$(IntDir)");
|
||||
|
@@ -84,3 +84,4 @@ endif()
|
||||
|
||||
run_cmake(VsDotnetTargetFramework)
|
||||
run_cmake(VsDotnetTargetFrameworkVersion)
|
||||
run_cmake(VsNoCompileBatching)
|
||||
|
31
Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake
Normal file
31
Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake
Normal file
@@ -0,0 +1,31 @@
|
||||
macro(VsNoCompileBatching_check tgt ofn_expect)
|
||||
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
|
||||
if(NOT EXISTS "${vcProjectFile}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(HAVE_OFN 0)
|
||||
|
||||
file(STRINGS "${vcProjectFile}" lines)
|
||||
foreach(line IN LISTS lines)
|
||||
if(line MATCHES "^ *<ObjectFileName>([^<>]+)</ObjectFileName>")
|
||||
set(ofn_actual "${CMAKE_MATCH_1}")
|
||||
if(NOT "${ofn_actual}" STREQUAL "${ofn_expect}")
|
||||
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <ObjectFileName> '${ofn_actual}', not '${ofn_expect}'.")
|
||||
return()
|
||||
endif()
|
||||
set(HAVE_OFN 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT HAVE_OFN)
|
||||
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <ObjectFileName> property.")
|
||||
return()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
VsNoCompileBatching_check(foo "$(IntDir)")
|
||||
VsNoCompileBatching_check(foo_NB "$(IntDir)%(filename).obj")
|
||||
VsNoCompileBatching_check(foo_NB_OFF "$(IntDir)")
|
9
Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake
Normal file
9
Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake
Normal file
@@ -0,0 +1,9 @@
|
||||
enable_language(CXX)
|
||||
|
||||
add_library(foo foo.cpp)
|
||||
|
||||
add_library(foo_NB foo.cpp)
|
||||
set_property(TARGET foo_NB PROPERTY VS_NO_COMPILE_BATCHING ON)
|
||||
|
||||
add_library(foo_NB_OFF foo.cpp)
|
||||
set_property(TARGET foo_NB_OFF PROPERTY VS_NO_COMPILE_BATCHING OFF)
|
Reference in New Issue
Block a user