فهرست منبع

VS: Add variable to to turn off Visual Studio compile batching

Extend the change from commit b764c7c273 (VS: Add property to turn off
Visual Studio compile batching, 2022-02-07, v3.24.0-rc1~710^2) by
adding a variable to initialize the property on every target.

Issue: #23179
Fixes: #23639
Brad King 3 سال پیش
والد
کامیت
9a0a94fdaa

+ 1 - 0
Help/manual/cmake-variables.7.rst

@@ -516,6 +516,7 @@ Variables that Control the Build
    /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
    /variable/CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD
    /variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
    /variable/CMAKE_VS_INCLUDE_PACKAGE_TO_DEFAULT_BUILD
    /variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING
    /variable/CMAKE_VS_JUST_MY_CODE_DEBUGGING
+   /variable/CMAKE_VS_NO_COMPILE_BATCHING
    /variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
    /variable/CMAKE_VS_SDK_EXCLUDE_DIRECTORIES
    /variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
    /variable/CMAKE_VS_SDK_EXECUTABLE_DIRECTORIES
    /variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES
    /variable/CMAKE_VS_SDK_INCLUDE_DIRECTORIES

+ 3 - 0
Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst

@@ -10,6 +10,9 @@ 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
 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.
 that replaces the compiler, for example some build caching tool.
 
 
+This property is initialized by the :variable:`CMAKE_VS_NO_COMPILE_BATCHING`
+variable if it is set when a target is created.
+
 Example
 Example
 ^^^^^^^
 ^^^^^^^
 
 

+ 5 - 4
Help/release/3.24.rst

@@ -154,6 +154,11 @@ Variables
   were added to enable build rules that verify all headers in header sets
   were added to enable build rules that verify all headers in header sets
   can be used on their own.
   can be used on their own.
 
 
+* The :variable:`CMAKE_VS_NO_COMPILE_BATCHING` variable and corresponding
+  :prop_tgt:`VS_NO_COMPILE_BATCHING` target property were added to
+  tell :ref:`Visual Studio Generators` whether to disable compiler
+  parallelism and call the compiler with one source file at a time.
+
 * The :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` variable and
 * The :variable:`CMAKE_WATCOM_RUNTIME_LIBRARY` variable and
   :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target property were introduced to
   :prop_tgt:`WATCOM_RUNTIME_LIBRARY` target property were introduced to
   select the runtime library used by compilers targeting the Watcom ABI.
   select the runtime library used by compilers targeting the Watcom ABI.
@@ -185,10 +190,6 @@ Properties
   than one ``static void Main(string[])`` function signature is available
   than one ``static void Main(string[])`` function signature is available
   in a managed .NET project.
   in a managed .NET project.
 
 
-* 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 source file at a time.
-
 Modules
 Modules
 -------
 -------
 
 

+ 20 - 0
Help/variable/CMAKE_VS_NO_COMPILE_BATCHING.rst

@@ -0,0 +1,20 @@
+CMAKE_VS_NO_COMPILE_BATCHING
+----------------------------
+
+.. versionadded:: 3.24
+
+Turn off compile batching when using :ref:`Visual Studio Generators`.
+
+This variable is used to initialize the :prop_tgt:`VS_NO_COMPILE_BATCHING`
+property on all targets when they are created.  See that target property for
+additional information.
+
+Example
+^^^^^^^
+
+This shows setting the property for the target ``foo`` using the variable.
+
+.. code-block:: cmake
+
+  set(CMAKE_VS_NO_COMPILE_BATCHING ON)
+  add_library(foo SHARED foo.cpp)

+ 1 - 0
Source/cmTarget.cxx

@@ -583,6 +583,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
     initProp("Swift_LANGUAGE_VERSION");
     initProp("Swift_LANGUAGE_VERSION");
     initProp("Swift_MODULE_DIRECTORY");
     initProp("Swift_MODULE_DIRECTORY");
     initProp("VS_JUST_MY_CODE_DEBUGGING");
     initProp("VS_JUST_MY_CODE_DEBUGGING");
+    initProp("VS_NO_COMPILE_BATCHING");
     initProp("DISABLE_PRECOMPILE_HEADERS");
     initProp("DISABLE_PRECOMPILE_HEADERS");
     initProp("UNITY_BUILD");
     initProp("UNITY_BUILD");
     initProp("UNITY_BUILD_UNIQUE_ID");
     initProp("UNITY_BUILD_UNIQUE_ID");

+ 1 - 1
Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake

@@ -2,8 +2,8 @@ enable_language(CXX)
 
 
 add_library(foo foo.cpp)
 add_library(foo foo.cpp)
 
 
+set(CMAKE_VS_NO_COMPILE_BATCHING ON)
 add_library(foo_NB 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)
 add_library(foo_NB_OFF foo.cpp)
 set_property(TARGET foo_NB_OFF PROPERTY VS_NO_COMPILE_BATCHING OFF)
 set_property(TARGET foo_NB_OFF PROPERTY VS_NO_COMPILE_BATCHING OFF)