summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Auxiliary/vim/syntax/cmake.vim1
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst21
-rw-r--r--Help/release/dev/vs_buildcache_support.rst6
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx4
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake31
-rw-r--r--Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake9
8 files changed, 73 insertions, 1 deletions
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim
index d5361bd326..381d97c213 100644
--- a/Auxiliary/vim/syntax/cmake.vim
+++ b/Auxiliary/vim/syntax/cmake.vim
@@ -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
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index f4efd3c66c..566eeaeefa 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -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
diff --git a/Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst b/Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst
new file mode 100644
index 0000000000..f8a9fa64b0
--- /dev/null
+++ b/Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst
@@ -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)
diff --git a/Help/release/dev/vs_buildcache_support.rst b/Help/release/dev/vs_buildcache_support.rst
new file mode 100644
index 0000000000..bdda675400
--- /dev/null
+++ b/Help/release/dev/vs_buildcache_support.rst
@@ -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.
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 7b197fa099..912210d4a8 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -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)");
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 139dcc79da..b19c1a8020 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -84,3 +84,4 @@ endif()
run_cmake(VsDotnetTargetFramework)
run_cmake(VsDotnetTargetFrameworkVersion)
+run_cmake(VsNoCompileBatching)
diff --git a/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake b/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake
new file mode 100644
index 0000000000..4002c3fc3b
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake
@@ -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)")
diff --git a/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake b/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake
new file mode 100644
index 0000000000..c96edce7ab
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake
@@ -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)