Browse Source

LCC: Add policy CMP0129 regarding interpreting LCC as GNU

Due to MCST LCC compiler identification is now changed to LCC,
there should be a way for old projects to still identify it as GNU,
as it was before.
This commits adds the policy:
CMP0129: Compiler id for MCST LCC compilers is now LCC, not GNU.
This policy controls such a behavior.
OLD behaivior is to treat LCC as GNU, NEW is to treat is as LCC.
makise-homura 4 years ago
parent
commit
3958ed878f
35 changed files with 287 additions and 4 deletions
  1. 5 0
      CMakeLists.txt
  2. 9 0
      Help/manual/cmake-policies.7.rst
  3. 34 0
      Help/policy/CMP0129.rst
  4. 1 0
      Help/release/dev/lcc-compiler.rst
  5. 2 0
      Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
  6. 21 0
      Modules/CMakeDetermineCompilerId.cmake
  7. 8 0
      Modules/Compiler/LCC-C-DetermineCompiler.cmake
  8. 8 0
      Modules/Compiler/LCC-CXX-DetermineCompiler.cmake
  9. 48 0
      Source/cmGlobalGenerator.cxx
  10. 4 1
      Source/cmPolicies.h
  11. 3 0
      Tests/Assembler/CMakeLists.txt
  12. 4 0
      Tests/CMakeCommands/add_compile_options/CMakeLists.txt
  13. 4 0
      Tests/CMakeCommands/target_compile_options/CMakeLists.txt
  14. 4 0
      Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
  15. 3 0
      Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt
  16. 3 0
      Tests/CompileOptions/CMakeLists.txt
  17. 3 0
      Tests/ExportImport/Export/CMakeLists.txt
  18. 3 0
      Tests/ExportImport/Import/CMakeLists.txt
  19. 3 0
      Tests/Fortran/CMakeLists.txt
  20. 5 1
      Tests/IncludeDirectories/CMakeLists.txt
  21. 3 0
      Tests/LinkStatic/CMakeLists.txt
  22. 3 0
      Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
  23. 8 0
      Tests/RunCMake/CMP0129/C.cmake
  24. 3 0
      Tests/RunCMake/CMP0129/CMakeLists.txt
  25. 8 0
      Tests/RunCMake/CMP0129/CXX.cmake
  26. 41 0
      Tests/RunCMake/CMP0129/CompareCompilerVersion.cmake
  27. 15 0
      Tests/RunCMake/CMP0129/Fortran.cmake
  28. 8 0
      Tests/RunCMake/CMP0129/RunCMakeTest.cmake
  29. 4 0
      Tests/RunCMake/CMakeLists.txt
  30. 4 0
      Tests/RunCMake/CPack/CMakeLists.txt
  31. 4 0
      Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt
  32. 3 0
      Tests/RunCMake/RunCMake.cmake
  33. 2 2
      Tests/RunCMake/try_compile/RunCMakeTest.cmake
  34. 3 0
      Tests/SetLang/CMakeLists.txt
  35. 3 0
      Tests/TryCompile/CMakeLists.txt

+ 5 - 0
CMakeLists.txt

@@ -4,6 +4,11 @@
 cmake_minimum_required(VERSION 3.1...3.21 FATAL_ERROR)
 set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
 set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
+
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW) # CMake 3.23
+endif()
+
 project(CMake)
 unset(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX)
 unset(CMAKE_USER_MAKE_RULES_OVERRIDE_C)

+ 9 - 0
Help/manual/cmake-policies.7.rst

@@ -51,6 +51,15 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used
 to determine whether to report an error on use of deprecated macros or
 functions.
 
+
+Policies Introduced by CMake 3.23
+=================================
+
+.. toctree::
+   :maxdepth: 1
+
+   CMP0129: Compiler id for MCST LCC compilers is now LCC, not GNU. </policy/CMP0129>
+
 Policies Introduced by CMake 3.22
 =================================
 

+ 34 - 0
Help/policy/CMP0129.rst

@@ -0,0 +1,34 @@
+CMP0129
+-------
+
+.. versionadded:: 3.23
+
+Compiler id for MCST LCC compilers is now ``LCC``, not ``GNU``.
+
+CMake 3.23 and above recognize MCST LCC compiler as a different from ``GNU``,
+with its own command line and set of capabilities.
+CMake now prefers to present this to projects by setting the
+:variable:`CMAKE_<LANG>_COMPILER_ID` variable to ``LCC`` instead
+of ``GNU``. However, existing projects may assume the compiler id for
+LCC is ``GNU`` as it was in CMake versions prior to 3.23.
+Therefore this policy determines for MCST LCC compiler which
+compiler id to report in the :variable:`CMAKE_<LANG>_COMPILER_ID`
+variable after language ``<LANG>`` is enabled by the :command:`project`
+or :command:`enable_language` command.  The policy must be set prior
+to the invocation of either command.
+
+The ``OLD`` behavior for this policy is to use compiler id ``GNU`` (and set
+:variable:`CMAKE_<LANG>_COMPILER_VERSION` to the supported GNU compiler version.)
+``NEW`` behavior for this policy is to use compiler id ``LCC``, and set
+:variable:`CMAKE_<LANG>_SIMULATE_ID` to ``GNU``, and
+:variable:`CMAKE_<LANG>_SIMULATE_VERSION` to the supported GNU compiler version.
+
+This policy was introduced in CMake version 3.23.  Use the
+:command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW`` explicitly.
+Unlike most policies, CMake version |release| does *not* warn
+by default when this policy is not set and simply uses ``OLD`` behavior.
+See documentation of the
+:variable:`CMAKE_POLICY_WARNING_CMP0129 <CMAKE_POLICY_WARNING_CMP<NNNN>>`
+variable to control the warning.
+
+.. include:: DEPRECATED.txt

+ 1 - 0
Help/release/dev/lcc-compiler.rst

@@ -2,3 +2,4 @@ lcc-compiler
 ------------
 
 * The MCST LCC compiler is now supported with compiler id ``LCC``.
+  See policy :policy:`CMP0129`.

+ 2 - 0
Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst

@@ -34,6 +34,8 @@ only for the policies that do not warn by default:
   policy :policy:`CMP0126`.
 * ``CMAKE_POLICY_WARNING_CMP0128`` controls the warning for
   policy :policy:`CMP0128`.
+* ``CMAKE_POLICY_WARNING_CMP0129`` controls the warning for
+  policy :policy:`CMP0129`.
 
 This variable should not be set by a project in CMake code.  Project
 developers running CMake may set this variable in their cache to

+ 21 - 0
Modules/CMakeDetermineCompilerId.cmake

@@ -150,6 +150,27 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
     endif()
   endif()
 
+  # For LCC Fortran we need to explicitly query the version.
+  if(lang STREQUAL "Fortran"
+     AND CMAKE_${lang}_COMPILER_ID STREQUAL "LCC")
+    execute_process(
+      COMMAND "${CMAKE_${lang}_COMPILER}"
+      --version
+      OUTPUT_VARIABLE output ERROR_VARIABLE output
+      RESULT_VARIABLE result
+      TIMEOUT 10
+    )
+    file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+      "Running the ${lang} compiler: \"${CMAKE_${lang}_COMPILER}\" --version\n"
+      "${output}\n"
+      )
+
+    if(output MATCHES [[\(GCC\) ([0-9]+\.[0-9]+(\.[0-9]+)?) compatible]])
+      set(CMAKE_${lang}_SIMULATE_ID "GNU")
+      set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_MATCH_1}")
+    endif()
+  endif()
+
   if (COMPILER_QNXNTO AND (CMAKE_${lang}_COMPILER_ID STREQUAL "GNU" OR CMAKE_${lang}_COMPILER_ID STREQUAL "LCC"))
     execute_process(
       COMMAND "${CMAKE_${lang}_COMPILER}"

+ 8 - 0
Modules/Compiler/LCC-C-DetermineCompiler.cmake

@@ -8,4 +8,12 @@ set(_compiler_id_version_compute "
 # endif
 # if defined(__LCC_MINOR__)
 #  define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__LCC_MINOR__)
+# endif
+# if defined(__GNUC__) && defined(__GNUC_MINOR__)
+#  define @PREFIX@SIMULATE_ID \"GNU\"
+#  define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(__GNUC__)
+#  define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__)
+#  if defined(__GNUC_PATCHLEVEL__)
+#   define @PREFIX@SIMULATE_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__)
+#  endif
 # endif")

+ 8 - 0
Modules/Compiler/LCC-CXX-DetermineCompiler.cmake

@@ -8,4 +8,12 @@ set(_compiler_id_version_compute "
 # endif
 # if defined(__LCC_MINOR__)
 #  define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__LCC_MINOR__)
+# endif
+# if defined(__GNUC__) && defined(__GNUC_MINOR__)
+#  define @PREFIX@SIMULATE_ID \"GNU\"
+#  define @PREFIX@SIMULATE_VERSION_MAJOR @MACRO_DEC@(__GNUC__)
+#  define @PREFIX@SIMULATE_VERSION_MINOR @MACRO_DEC@(__GNUC_MINOR__)
+#  if defined(__GNUC_PATCHLEVEL__)
+#   define @PREFIX@SIMULATE_VERSION_PATCH @MACRO_DEC@(__GNUC_PATCHLEVEL__)
+#  endif
 # endif")

+ 48 - 0
Source/cmGlobalGenerator.cxx

@@ -1038,6 +1038,54 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(
         break;
     }
   }
+
+  if (compilerId == "LCC") {
+    switch (mf->GetPolicyStatus(cmPolicies::CMP0129)) {
+      case cmPolicies::WARN:
+        if (!this->CMakeInstance->GetIsInTryCompile() &&
+            mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0129")) {
+          std::ostringstream w;
+          /* clang-format off */
+          w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0129) << "\n"
+            "Converting " << lang <<
+            R"( compiler id "LCC" to "GNU" for compatibility.)"
+            ;
+          /* clang-format on */
+          mf->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+        }
+        CM_FALLTHROUGH;
+      case cmPolicies::OLD:
+        // OLD behavior is to convert LCC to GNU.
+        mf->AddDefinition(compilerIdVar, "GNU");
+        if (lang == "C") {
+          mf->AddDefinition("CMAKE_COMPILER_IS_GNUCC", "1");
+        } else if (lang == "CXX") {
+          mf->AddDefinition("CMAKE_COMPILER_IS_GNUCXX", "1");
+        } else if (lang == "Fortran") {
+          mf->AddDefinition("CMAKE_COMPILER_IS_GNUG77", "1");
+        }
+        {
+          // Fix compiler versions.
+          std::string version = "CMAKE_" + lang + "_COMPILER_VERSION";
+          std::string emulated = "CMAKE_" + lang + "_SIMULATE_VERSION";
+          std::string emulatedId = "CMAKE_" + lang + "_SIMULATE_ID";
+          std::string const& actual = mf->GetRequiredDefinition(emulated);
+          mf->AddDefinition(version, actual);
+          mf->RemoveDefinition(emulatedId);
+          mf->RemoveDefinition(emulated);
+        }
+        break;
+      case cmPolicies::REQUIRED_IF_USED:
+      case cmPolicies::REQUIRED_ALWAYS:
+        mf->IssueMessage(
+          MessageType::FATAL_ERROR,
+          cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0129));
+        CM_FALLTHROUGH;
+      case cmPolicies::NEW:
+        // NEW behavior is to keep LCC.
+        break;
+    }
+  }
 }
 
 std::string cmGlobalGenerator::GetLanguageOutputExtension(

+ 4 - 1
Source/cmPolicies.h

@@ -385,7 +385,10 @@ class cmMakefile;
          0, cmPolicies::WARN)                                                 \
   SELECT(POLICY, CMP0128,                                                     \
          "Selection of language standard and extension flags improved.", 3,   \
-         22, 0, cmPolicies::WARN)
+         22, 0, cmPolicies::WARN)                                             \
+  SELECT(POLICY, CMP0129,                                                     \
+         "Compiler id for MCST LCC compilers is now LCC, not GNU.", 3, 23, 0, \
+         cmPolicies::WARN)
 
 #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
 #define CM_FOR_EACH_POLICY_ID(POLICY)                                         \

+ 3 - 0
Tests/Assembler/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required (VERSION 3.8)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(Assembler C)
 message("CTEST_FULL_OUTPUT ")
 set(CMAKE_VERBOSE_MAKEFILE 1)

+ 4 - 0
Tests/CMakeCommands/add_compile_options/CMakeLists.txt

@@ -1,5 +1,9 @@
 cmake_minimum_required(VERSION 2.8.12)
 
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
+
 project(add_compile_options)
 
 add_compile_options(-DTEST_OPTION)

+ 4 - 0
Tests/CMakeCommands/target_compile_options/CMakeLists.txt

@@ -1,6 +1,10 @@
 
 cmake_minimum_required(VERSION 2.8.12)
 
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
+
 project(target_compile_options)
 
 add_executable(target_compile_options

+ 4 - 0
Tests/CMakeCommands/target_link_libraries/CMakeLists.txt

@@ -3,6 +3,10 @@
 # 2.8.12
 cmake_minimum_required(VERSION 2.8)
 
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
+
 project(target_link_libraries)
 
 file(WRITE

+ 3 - 0
Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required(VERSION 2.8.12)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(CheckCXXCompilerFlag)
 
 message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")

+ 3 - 0
Tests/CompileOptions/CMakeLists.txt

@@ -2,6 +2,9 @@ cmake_minimum_required(VERSION 3.0)
 if(POLICY CMP0092)
   cmake_policy(SET CMP0092 NEW)
 endif()
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
 if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE)
   set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE)

+ 3 - 0
Tests/ExportImport/Export/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required (VERSION 2.7.20090711)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(Export C CXX)
 
 # Pretend that RelWithDebInfo should link to debug libraries to test

+ 3 - 0
Tests/ExportImport/Import/CMakeLists.txt

@@ -1,5 +1,8 @@
 cmake_minimum_required (VERSION 2.7.20090711)
 cmake_policy(SET CMP0025 NEW)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(Import C CXX)
 
 # Import everything in a subdirectory.

+ 3 - 0
Tests/Fortran/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required (VERSION 3.1)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(testf C CXX Fortran)
 
 message("CTEST_FULL_OUTPUT ")

+ 5 - 1
Tests/IncludeDirectories/CMakeLists.txt

@@ -1,6 +1,10 @@
 cmake_minimum_required (VERSION 2.6)
-project(IncludeDirectories)
 
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
+
+project(IncludeDirectories)
 if (((CMAKE_C_COMPILER_ID STREQUAL GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.4)
     OR (CMAKE_C_COMPILER_ID STREQUAL Clang AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
     OR CMAKE_C_COMPILER_ID STREQUAL AppleClang

+ 3 - 0
Tests/LinkStatic/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required(VERSION 2.8.4.20110303 FATAL_ERROR)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(LinkStatic C)
 
 if(NOT CMAKE_C_COMPILER_ID MATCHES "GNU|LCC")

+ 3 - 0
Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required(VERSION 3.1.0)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(WriteCompilerDetectionHeader)
 
 set(CMAKE_INCLUDE_CURRENT_DIR ON)

+ 8 - 0
Tests/RunCMake/CMP0129/C.cmake

@@ -0,0 +1,8 @@
+if(SET_CMP0129)
+  cmake_policy(SET CMP0129 ${SET_CMP0129})
+endif()
+
+enable_language(C)
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+include(CompareCompilerVersion.cmake)
+compare_compiler_version(C)

+ 3 - 0
Tests/RunCMake/CMP0129/CMakeLists.txt

@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)

+ 8 - 0
Tests/RunCMake/CMP0129/CXX.cmake

@@ -0,0 +1,8 @@
+if(SET_CMP0129)
+  cmake_policy(SET CMP0129 ${SET_CMP0129})
+endif()
+
+enable_language(CXX)
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+include(CompareCompilerVersion.cmake)
+compare_compiler_version(CXX)

+ 41 - 0
Tests/RunCMake/CMP0129/CompareCompilerVersion.cmake

@@ -0,0 +1,41 @@
+function(compare_compiler_version lang)
+  cmake_policy(GET CMP0129 LCC_FALLBACK_MODE)
+  if(${CMAKE_${lang}_COMPILER} STREQUAL "LCC" OR ${CMAKE_${lang}_COMPILER} STREQUAL "GNU")
+    execute_process(COMMAND ${CMAKE_${lang}_COMPILER} --version OUTPUT_VARIABLE output)
+    if("${output}" MATCHES [[lcc:([0-9]+.[0-9]+.([0-9]+)):]])
+      set(native_version ${CMAKE_MATCH_1})
+    else()
+      message(FATAL_ERROR "Can not identify native LCC version for language ${lang}.")
+    endif()
+    if("${output}" MATCHES [[\(GCC\) ([0-9]+.[0-9]+.([0-9]+)) compatible]])
+      set(simulated_version ${CMAKE_MATCH_1})
+    else()
+      message(FATAL_ERROR "Can not identify simulated GNU version for language ${lang}.")
+    endif()
+    message(STATUS "Compiler native version is ${native_version}, simulated version is ${simulated_version}.")
+    if("${LCC_FALLBACK_MODE}" STREQUAL "NEW")
+      if(NOT "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "LCC")
+        message(FATAL_ERROR "Policy is in NEW mode, but compiler identification is ${CMAKE_${lang}_COMPILER_ID} instead of LCC.")
+      endif()
+      if(NOT "${CMAKE_${lang}_COMPILER_VERSION}" STREQUAL "${native_version}")
+        message(FATAL_ERROR "Policy is in NEW mode, but compiler version is ${CMAKE_${lang}_COMPILER_VERSION} instead of ${native_version}.")
+      endif()
+      if(NOT "${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "GNU")
+        message(FATAL_ERROR "Policy is in NEW mode, but simulated compiler identification is ${CMAKE_${lang}_SIMULATE_ID} instead of GNU.")
+      endif()
+      if(NOT "${CMAKE_${lang}_SIMULATE_VERSION}" STREQUAL "${simulated_version}")
+        message(FATAL_ERROR "Policy is in NEW mode, but simulated compiler version is ${CMAKE_${lang}_SIMULATE_VERSION} instead of ${simulated_version}.")
+      endif()
+    else()
+      if(NOT "${CMAKE_${lang}_COMPILER_ID}" STREQUAL "GNU")
+        message(FATAL_ERROR "Policy is in OLD mode, but compiler identification is ${CMAKE_${lang}_COMPILER_ID} instead of GNU.")
+      endif()
+      if(NOT "${CMAKE_${lang}_COMPILER_VERSION}" STREQUAL "${simulated_version}")
+        message(FATAL_ERROR "Policy is in OLD mode, but compiler version is ${CMAKE_${lang}_COMPILER_VERSION} instead of ${simulated_version}.")
+      endif()
+      if(${CMAKE_${lang}_SIMULATE_VERSION} OR ${CMAKE_${lang}_SIMULATE_ID)
+        message(FATAL_ERROR "Policy is in OLD mode, but simulated compiler ID/version is ${CMAKE_${lang}_COMPILER_ID}/${CMAKE_${lang}_COMPILER_VERSION} instead of undefined.")
+      endif()
+    endif()
+  endif()
+endfunction()

+ 15 - 0
Tests/RunCMake/CMP0129/Fortran.cmake

@@ -0,0 +1,15 @@
+include(CheckLanguage)
+check_language(Fortran)
+if(NOT CMAKE_Fortran_COMPILER)
+  # No Fortran compiler, skipping Fortran test
+  return()
+endif()
+
+if(SET_CMP0129)
+  cmake_policy(SET CMP0129 ${SET_CMP0129})
+endif()
+
+enable_language(Fortran)
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+include(CompareCompilerVersion.cmake)
+compare_compiler_version(Fortran)

+ 8 - 0
Tests/RunCMake/CMP0129/RunCMakeTest.cmake

@@ -0,0 +1,8 @@
+set(RunCMake_TEST_NO_CMP0129 ON)
+include(RunCMake)
+
+foreach(lang C CXX Fortran)
+  run_cmake(${lang})
+  run_cmake_with_options(${lang} "-DSET_CMP0129=NEW")
+  run_cmake_with_options(${lang} "-DSET_CMP0129=OLD")
+endforeach()

+ 4 - 0
Tests/RunCMake/CMakeLists.txt

@@ -928,3 +928,7 @@ endif()
 if(WIN32)
   add_RunCMake_test(Win32GenEx)
 endif()
+
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LCC")
+  add_RunCMake_test("CMP0129")
+endif()

+ 4 - 0
Tests/RunCMake/CPack/CMakeLists.txt

@@ -1,5 +1,9 @@
 cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
 
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
+
 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "")
 
 project(${RunCMake_TEST} CXX)

+ 4 - 0
Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt

@@ -1,5 +1,9 @@
 cmake_minimum_required(VERSION 3.13)
 
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
+
 project(${RunCMake_TEST} LANGUAGES NONE)
 
 include(${RunCMake_TEST}.cmake)

+ 3 - 0
Tests/RunCMake/RunCMake.cmake

@@ -92,6 +92,9 @@ function(run_cmake test)
     if(APPLE)
       list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
     endif()
+    if(NOT RunCMake_TEST_NO_CMP0129 AND CMAKE_C_COMPILER_ID STREQUAL "LCC")
+      list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0129=NEW)
+    endif()
     if(RunCMake_MAKE_PROGRAM)
       list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_MAKE_PROGRAM=${RunCMake_MAKE_PROGRAM}")
     endif()

+ 2 - 2
Tests/RunCMake/try_compile/RunCMakeTest.cmake

@@ -60,10 +60,10 @@ if(CMake_TEST_ISPC)
   endif()
   run_cmake(ISPCDuplicateTarget${ninja})
 endif()
-if(CMAKE_C_COMPILER_ID MATCHES "GNU|LCC" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4)
+if((CMAKE_C_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.4) OR CMAKE_C_COMPILER_ID MATCHES "LCC")
   run_cmake(CStandardGNU)
 endif()
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
+if((CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) OR CMAKE_C_COMPILER_ID MATCHES "LCC")
   run_cmake(CxxStandardGNU)
 endif()
 

+ 3 - 0
Tests/SetLang/CMakeLists.txt

@@ -1,5 +1,8 @@
 # test forcing a source file language to c++ from c
 cmake_minimum_required (VERSION 2.6)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(SetLang)
 # force this to be verbose so I can debug a dashboard entry
 set(CMAKE_VERBOSE_MAKEFILE 1)

+ 3 - 0
Tests/TryCompile/CMakeLists.txt

@@ -1,4 +1,7 @@
 cmake_minimum_required (VERSION 2.8.12)
+if(POLICY CMP0129)
+  cmake_policy(SET CMP0129 NEW)
+endif()
 project(TryCompile)
 
 macro(TEST_ASSERT value msg)