فهرست منبع

Genex: Enable COMPILE_LANGUAGE for COMPILE_DEFINITIONS with VS and Xcode

The set of compile flags used for a target's C and C++ sources is based
on the linker language.  By default this is always the C++ flags if any
C++ sources appear in the target, and otherwise the C flags.  Therefore
we can define the `COMPILE_LANGUAGE` generator expression in
`COMPILE_DEFINITIONS` to match the selected language.

This is not exactly the same as for other generators, but is the best VS
and Xcode can do.  It is also sufficient for many use cases since the
set of definitions for C and C++ is frequently similar but may be
distinct from those for other languages like CUDA.

Issue: #17435
Brad King 8 سال پیش
والد
کامیت
c2f79c9867
24فایلهای تغییر یافته به همراه107 افزوده شده و 115 حذف شده
  1. 16 11
      Help/manual/cmake-generator-expressions.7.rst
  2. 10 4
      Help/release/dev/extend-compile-language-genex.rst
  3. 6 6
      Source/cmGeneratorExpressionNode.cxx
  4. 5 1
      Source/cmGlobalXCodeGenerator.cxx
  5. 5 2
      Source/cmLocalVisualStudio7Generator.cxx
  6. 6 3
      Source/cmVisualStudio10TargetGenerator.cxx
  7. 1 0
      Source/cmVisualStudio10TargetGenerator.h
  8. 11 11
      Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
  9. 19 1
      Tests/CMakeCommands/target_compile_definitions/consumer.c
  10. 0 2
      Tests/CMakeCommands/target_compile_definitions/consumer.cpp
  11. 4 2
      Tests/CudaOnly/WithDefs/CMakeLists.txt
  12. 18 6
      Tests/CudaOnly/WithDefs/main.notcu
  13. 2 4
      Tests/GeneratorExpression/CMakeLists.txt
  14. 0 1
      Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt
  15. 0 9
      Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt
  16. 0 9
      Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt
  17. 0 5
      Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake
  18. 2 2
      Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt
  19. 2 2
      Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt
  20. 0 1
      Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt
  21. 0 7
      Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt
  22. 0 7
      Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt
  23. 0 5
      Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake
  24. 0 14
      Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake

+ 16 - 11
Help/manual/cmake-generator-expressions.7.rst

@@ -97,10 +97,9 @@ Available logical expressions are:
   compile features and a list of supported compilers.
 ``$<COMPILE_LANGUAGE:lang>``
   ``1`` when the language used for compilation unit matches ``lang``,
-  otherwise ``0``.  This expression may be used to specify compile options for
-  source files of a particular language in a target. For example, to specify
-  the use of the ``-fno-exceptions`` compile option (compiler id checks
-  elided):
+  otherwise ``0``.  This expression may be used to specify compile options
+  and compile definitions for source files of a
+  particular language in a target. For example:
 
   .. code-block:: cmake
 
@@ -108,10 +107,20 @@ Available logical expressions are:
     target_compile_options(myapp
       PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
     )
+    target_compile_definitions(myapp
+      PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
+    )
+
+  This specifies the use of the ``-fno-exceptions`` compile option
+  and ``COMPILING_CXX`` compile definition for C++ only
+  (compiler id checks elided).
 
-  Note that with :ref:`Visual Studio Generators` there is no way to represent
+  Note that with :ref:`Visual Studio Generators` and :generator:`Xcode` there
+  is no way to represent target-wide compile definitions separately for
+  ``C`` and ``CXX`` languages.
+  Also, with :ref:`Visual Studio Generators` there is no way to represent
   target-wide flags separately for ``C`` and ``CXX`` languages.  Under these
-  generators, target-wide flags for both C and C++ sources will be evaluated
+  generators, expressions for both C and C++ sources will be evaluated
   using ``CXX`` if there are any C++ sources and otherwise using ``C``.
   A workaround is to create separate libraries for each source file language
   instead:
@@ -125,15 +134,11 @@ Available logical expressions are:
     target_link_libraries(myapp myapp_c myapp_cxx)
 
   The ``Makefile`` and ``Ninja`` based generators can also use this
-  expression to specify compile-language specific compile definitions
-  and include directories:
+  expression to specify compile-language specific include directories:
 
   .. code-block:: cmake
 
     add_executable(myapp main.cpp foo.c bar.cpp)
-    target_compile_definitions(myapp
-      PRIVATE $<$<COMPILE_LANGUAGE:CXX>:COMPILING_CXX>
-    )
     target_include_directories(myapp
       PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/opt/foo/cxx_headers>
     )

+ 10 - 4
Help/release/dev/extend-compile-language-genex.rst

@@ -1,7 +1,13 @@
 extend-compile-language-genex
 -----------------------------
 
-* The ``COMPILE_LANGUAGE`` :manual:`generator expression
-  <cmake-generator-expressions(7)>` may now be used with
-  :ref:`Visual Studio Generators` in :prop_tgt:`COMPILE_OPTIONS`
-  and :command:`file(GENERATE)`.
+* :ref:`Visual Studio Generators` learned to support the ``COMPILE_LANGUAGE``
+  :manual:`generator expression <cmake-generator-expressions(7)>` in
+  target-wide :prop_tgt:`COMPILE_DEFINITIONS`,
+  :prop_tgt:`COMPILE_OPTIONS`, and :command:`file(GENERATE)`.
+
+* The :generator:`Xcode` generator learned to support the ``COMPILE_LANGUAGE``
+  :manual:`generator expression <cmake-generator-expressions(7)>` in
+  target-wide :prop_tgt:`COMPILE_DEFINITIONS`.
+  It previously supported only :prop_tgt:`COMPILE_OPTIONS` and
+  :command:`file(GENERATE)`.

+ 6 - 6
Source/cmGeneratorExpressionNode.cxx

@@ -828,20 +828,20 @@ static const struct CompileLanguageNode : public cmGeneratorExpressionNode
     }
     std::string genName = gg->GetName();
     if (genName.find("Visual Studio") != std::string::npos) {
-      if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
-                         dagChecker->EvaluatingIncludeDirectories())) {
+      if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
         reportError(
           context, content->GetOriginalExpression(),
-          "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS "
+          "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
+          "COMPILE_DEFINITIONS, "
           "and file(GENERATE) with the Visual Studio generator.");
         return std::string();
       }
     } else if (genName.find("Xcode") != std::string::npos) {
-      if (dagChecker && (dagChecker->EvaluatingCompileDefinitions() ||
-                         dagChecker->EvaluatingIncludeDirectories())) {
+      if (dagChecker && dagChecker->EvaluatingIncludeDirectories()) {
         reportError(
           context, content->GetOriginalExpression(),
-          "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS "
+          "$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS, "
+          "COMPILE_DEFINITIONS, "
           "and file(GENERATE) with the Xcode generator.");
         return std::string();
       }

+ 5 - 1
Source/cmGlobalXCodeGenerator.cxx

@@ -1703,6 +1703,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
       gtgt->GetName().c_str());
     return;
   }
+  std::string const& langForPreprocessor = llang;
 
   if (gtgt->IsIPOEnabled(llang, configName)) {
     const char* ltoValue =
@@ -1723,7 +1724,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
     this->AppendDefines(ppDefs, exportMacro);
   }
   std::vector<std::string> targetDefines;
-  gtgt->GetCompileDefinitions(targetDefines, configName, "C");
+  if (!langForPreprocessor.empty()) {
+    gtgt->GetCompileDefinitions(targetDefines, configName,
+                                langForPreprocessor);
+  }
   this->AppendDefines(ppDefs, targetDefines);
   buildSettings->AddAttribute("GCC_PREPROCESSOR_DEFINITIONS",
                               ppDefs.CreateList());

+ 5 - 2
Source/cmLocalVisualStudio7Generator.cxx

@@ -705,7 +705,9 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
   targetOptions.Parse(defineFlags.c_str());
   targetOptions.ParseFinish();
   std::vector<std::string> targetDefines;
-  target->GetCompileDefinitions(targetDefines, configName, "CXX");
+  if (!langForClCompile.empty()) {
+    target->GetCompileDefinitions(targetDefines, configName, langForClCompile);
+  }
   targetOptions.AddDefines(targetDefines);
   targetOptions.SetVerboseMakefile(
     this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"));
@@ -812,7 +814,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
   }
   fout << "\"\n";
   targetOptions.OutputFlagMap(fout, "\t\t\t\t");
-  targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
+  targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n",
+                                              langForClCompile);
   fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
   if (target->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
     // Specify the compiler program database file if configured.

+ 6 - 3
Source/cmVisualStudio10TargetGenerator.cxx

@@ -2391,6 +2391,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
       }
     }
   }
+  this->LangForClCompile = langForClCompile;
   if (!langForClCompile.empty()) {
     std::string baseFlagVar = "CMAKE_";
     baseFlagVar += langForClCompile;
@@ -2434,8 +2435,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
   std::vector<std::string> targetDefines;
   switch (this->ProjectType) {
     case vcxproj:
-      this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
-                                                   "CXX");
+      if (!langForClCompile.empty()) {
+        this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
+                                                     langForClCompile);
+      }
       break;
     case csproj:
       this->GeneratorTarget->GetCompileDefinitions(targetDefines, configName,
@@ -2512,7 +2515,7 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
                        "%(AdditionalIncludeDirectories)");
   clOptions.OutputFlagMap(*this->BuildFileStream, "      ");
   clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, "      ",
-                                          "\n", "CXX");
+                                          "\n", this->LangForClCompile);
 
   if (this->NsightTegra) {
     if (const char* processMax =

+ 1 - 0
Source/cmVisualStudio10TargetGenerator.h

@@ -183,6 +183,7 @@ private:
   OptionsMap MasmOptions;
   OptionsMap NasmOptions;
   OptionsMap LinkOptions;
+  std::string LangForClCompile;
   std::string PathToProjectFile;
   std::string ProjectFileExtension;
   enum VsProjectType

+ 11 - 11
Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt

@@ -26,18 +26,18 @@ target_compile_definitions(consumer
   PRIVATE
 )
 
-if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja")
-  target_sources(consumer PRIVATE
-    "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
-  )
-  target_compile_definitions(consumer
-    PRIVATE
-      CONSUMER_LANG_$<COMPILE_LANGUAGE>
-      LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
-      LANG_IS_C=$<COMPILE_LANGUAGE:C>
-  )
+target_sources(consumer PRIVATE
+  "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c"
+)
+target_compile_definitions(consumer
+  PRIVATE
+    CONSUMER_LANG_$<COMPILE_LANGUAGE>
+    LANG_IS_CXX=$<COMPILE_LANGUAGE:CXX>
+    LANG_IS_C=$<COMPILE_LANGUAGE:C>
+)
+if(CMAKE_GENERATOR MATCHES "Visual Studio|Xcode")
   target_compile_definitions(consumer
-    PRIVATE -DTEST_LANG_DEFINES
+    PRIVATE TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
   )
 endif()
 

+ 19 - 1
Tests/CMakeCommands/target_compile_definitions/consumer.c

@@ -1,5 +1,23 @@
 
-#ifdef TEST_LANG_DEFINES
+// Visual Studio allows only one set of flags for C and C++.
+// In a target using C++ we pick the C++ flags even for C sources.
+#ifdef TEST_LANG_DEFINES_FOR_VISUAL_STUDIO_OR_XCODE
+#ifndef CONSUMER_LANG_CXX
+#error Expected CONSUMER_LANG_CXX
+#endif
+
+#ifdef CONSUMER_LANG_C
+#error Unexpected CONSUMER_LANG_C
+#endif
+
+#if !LANG_IS_CXX
+#error Expected LANG_IS_CXX
+#endif
+
+#if LANG_IS_C
+#error Unexpected LANG_IS_C
+#endif
+#else
 #ifdef CONSUMER_LANG_CXX
 #error Unexpected CONSUMER_LANG_CXX
 #endif

+ 0 - 2
Tests/CMakeCommands/target_compile_definitions/consumer.cpp

@@ -15,7 +15,6 @@
 #error Expected DASH_D_DEFINE
 #endif
 
-#ifdef TEST_LANG_DEFINES
 #ifndef CONSUMER_LANG_CXX
 #error Expected CONSUMER_LANG_CXX
 #endif
@@ -31,7 +30,6 @@
 #if LANG_IS_C
 #error Unexpected LANG_IS_C
 #endif
-#endif
 
 int main()
 {

+ 4 - 2
Tests/CudaOnly/WithDefs/CMakeLists.txt

@@ -32,8 +32,8 @@ add_executable(CudaOnlyWithDefs ${main})
 
 target_compile_options(CudaOnlyWithDefs
   PRIVATE
-    -DCOMPILE_LANG_$<COMPILE_LANGUAGE>
-    -DLANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
+    -DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
+    -DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
     -Xcompiler=-DHOST_DEFINE
     $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
   )
@@ -41,6 +41,8 @@ target_compile_options(CudaOnlyWithDefs
 target_compile_definitions(CudaOnlyWithDefs
   PRIVATE
     $<$<CONFIG:RELEASE>:$<BUILD_INTERFACE:${release_compile_defs}>>
+    -DDEF_COMPILE_LANG_$<COMPILE_LANGUAGE>
+    -DDEF_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
   )
 
 if(APPLE)

+ 18 - 6
Tests/CudaOnly/WithDefs/main.notcu

@@ -10,16 +10,28 @@
 #error "PACKED_DEFINE not defined!"
 #endif
 
-#ifndef COMPILE_LANG_CUDA
-#error "COMPILE_LANG_CUDA not defined!"
+#ifndef FLAG_COMPILE_LANG_CUDA
+#error "FLAG_COMPILE_LANG_CUDA not defined!"
 #endif
 
-#ifndef LANG_IS_CUDA
-#error "LANG_IS_CUDA not defined!"
+#ifndef FLAG_LANG_IS_CUDA
+#error "FLAG_LANG_IS_CUDA not defined!"
 #endif
 
-#if !LANG_IS_CUDA
-#error "Expected LANG_IS_CUDA"
+#if !FLAG_LANG_IS_CUDA
+#error "Expected FLAG_LANG_IS_CUDA"
+#endif
+
+#ifndef DEF_COMPILE_LANG_CUDA
+#error "DEF_COMPILE_LANG_CUDA not defined!"
+#endif
+
+#ifndef DEF_LANG_IS_CUDA
+#error "DEF_LANG_IS_CUDA not defined!"
+#endif
+
+#if !DEF_LANG_IS_CUDA
+#error "Expected DEF_LANG_IS_CUDA"
 #endif
 
 static __global__ void DetermineIfValidCudaDevice()

+ 2 - 4
Tests/GeneratorExpression/CMakeLists.txt

@@ -269,10 +269,8 @@ set_property(SOURCE srcgenex_flags_COMPILE_LANGUAGE.c PROPERTY COMPILE_FLAGS "$<
 add_executable(srcgenex_defs srcgenex_defs.c)
 set_property(SOURCE srcgenex_defs.c PROPERTY COMPILE_DEFINITIONS NAME=$<TARGET_PROPERTY:NAME>)
 
-if (CMAKE_GENERATOR MATCHES "Makefiles|Ninja|Watcom WMake")
-  add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c)
-  set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>)
-endif()
+add_executable(srcgenex_defs_COMPILE_LANGUAGE srcgenex_defs_COMPILE_LANGUAGE.c)
+set_property(SOURCE srcgenex_defs_COMPILE_LANGUAGE.c PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:C>:NAME=$<TARGET_PROPERTY:NAME>>)
 
 #-----------------------------------------------------------------------------
 # Cover test properties with generator expressions.

+ 0 - 1
Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-result.txt

@@ -1 +0,0 @@
-1

+ 0 - 9
Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-VS.txt

@@ -1,9 +0,0 @@
-CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
-  Error evaluating generator expression:
-
-    \$<COMPILE_LANGUAGE:CXX>
-
-  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
-  file\(GENERATE\) with the Visual Studio generator.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)

+ 0 - 9
Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions-stderr-Xcode.txt

@@ -1,9 +0,0 @@
-CMake Error at CompileDefinitions.cmake:5 \(target_compile_definitions\):
-  Error evaluating generator expression:
-
-    \$<COMPILE_LANGUAGE:CXX>
-
-  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
-  file\(GENERATE\) with the Xcode generator.
-Call Stack \(most recent call first\):
-  CMakeLists.txt:3 \(include\)

+ 0 - 5
Tests/RunCMake/COMPILE_LANGUAGE-genex/CompileDefinitions.cmake

@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-target_compile_definitions(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:-DANYTHING>)

+ 2 - 2
Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-VS.txt

@@ -3,7 +3,7 @@ CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
 
     \$<COMPILE_LANGUAGE:CXX>
 
-  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
-  file\(GENERATE\) with the Visual Studio generator.
+  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS,
+  COMPILE_DEFINITIONS, and file\(GENERATE\) with the Visual Studio generator.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 2 - 2
Tests/RunCMake/COMPILE_LANGUAGE-genex/IncludeDirectories-stderr-Xcode.txt

@@ -3,7 +3,7 @@ CMake Error at IncludeDirectories.cmake:5 \(target_include_directories\):
 
     \$<COMPILE_LANGUAGE:CXX>
 
-  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
-  file\(GENERATE\) with the Xcode generator.
+  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS,
+  COMPILE_DEFINITIONS, and file\(GENERATE\) with the Xcode generator.
 Call Stack \(most recent call first\):
   CMakeLists.txt:3 \(include\)

+ 0 - 1
Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-result.txt

@@ -1 +0,0 @@
-1

+ 0 - 7
Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-VS.txt

@@ -1,7 +0,0 @@
-CMake Error:
-  Error evaluating generator expression:
-
-    \$<COMPILE_LANGUAGE:CXX>
-
-  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
-  file\(GENERATE\) with the Visual Studio generator.

+ 0 - 7
Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions-stderr-Xcode.txt

@@ -1,7 +0,0 @@
-CMake Error:
-  Error evaluating generator expression:
-
-    \$<COMPILE_LANGUAGE:CXX>
-
-  \$<COMPILE_LANGUAGE:...> may only be used for COMPILE_OPTIONS and
-  file\(GENERATE\) with the Xcode generator.

+ 0 - 5
Tests/RunCMake/COMPILE_LANGUAGE-genex/PerSourceCompileDefinitions.cmake

@@ -1,5 +0,0 @@
-
-enable_language(CXX)
-
-add_executable(main main.cpp)
-set_property(SOURCE main.cpp PROPERTY COMPILE_DEFINITIONS $<$<COMPILE_LANGUAGE:CXX>:ANYTHING>)

+ 0 - 14
Tests/RunCMake/COMPILE_LANGUAGE-genex/RunCMakeTest.cmake

@@ -1,12 +1,5 @@
 include(RunCMake)
 
-if (RunCMake_GENERATOR STREQUAL "Xcode")
-    set(RunCMake-stderr-file CompileDefinitions-stderr-Xcode.txt)
-    run_cmake(CompileDefinitions)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
-    set(RunCMake-stderr-file CompileDefinitions-stderr-VS.txt)
-    run_cmake(CompileDefinitions)
-endif()
 if (RunCMake_GENERATOR STREQUAL "Xcode")
     set(RunCMake-stderr-file IncludeDirectories-stderr-Xcode.txt)
     run_cmake(IncludeDirectories)
@@ -14,10 +7,3 @@ elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
     set(RunCMake-stderr-file IncludeDirectories-stderr-VS.txt)
     run_cmake(IncludeDirectories)
 endif()
-if (RunCMake_GENERATOR STREQUAL "Xcode")
-    set(RunCMake-stderr-file PerSourceCompileDefinitions-stderr-Xcode.txt)
-    run_cmake(PerSourceCompileDefinitions)
-elseif (RunCMake_GENERATOR MATCHES "Visual Studio")
-    set(RunCMake-stderr-file PerSourceCompileDefinitions-stderr-VS.txt)
-    run_cmake(PerSourceCompileDefinitions)
-endif()