summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormakise-homura <akemi_homura@kurisa.ch>2021-10-19 21:43:45 +0300
committermakise-homura <akemi_homura@kurisa.ch>2021-10-21 17:24:22 +0300
commit3958ed878f2365fd1af004341d45dac7f4e94afb (patch)
tree0192b68ccf8fc248efadb1bf91deddc1927bf434
parent52ea22ca65d86627e9ab571f2a87d4a952a7d85e (diff)
downloadcmake-3958ed878f2365fd1af004341d45dac7f4e94afb.tar.gz
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.
-rw-r--r--CMakeLists.txt5
-rw-r--r--Help/manual/cmake-policies.7.rst9
-rw-r--r--Help/policy/CMP0129.rst34
-rw-r--r--Help/release/dev/lcc-compiler.rst1
-rw-r--r--Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst2
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake21
-rw-r--r--Modules/Compiler/LCC-C-DetermineCompiler.cmake8
-rw-r--r--Modules/Compiler/LCC-CXX-DetermineCompiler.cmake8
-rw-r--r--Source/cmGlobalGenerator.cxx48
-rw-r--r--Source/cmPolicies.h5
-rw-r--r--Tests/Assembler/CMakeLists.txt3
-rw-r--r--Tests/CMakeCommands/add_compile_options/CMakeLists.txt4
-rw-r--r--Tests/CMakeCommands/target_compile_options/CMakeLists.txt4
-rw-r--r--Tests/CMakeCommands/target_link_libraries/CMakeLists.txt4
-rw-r--r--Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt3
-rw-r--r--Tests/CompileOptions/CMakeLists.txt3
-rw-r--r--Tests/ExportImport/Export/CMakeLists.txt3
-rw-r--r--Tests/ExportImport/Import/CMakeLists.txt3
-rw-r--r--Tests/Fortran/CMakeLists.txt3
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt6
-rw-r--r--Tests/LinkStatic/CMakeLists.txt3
-rw-r--r--Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0129/C.cmake8
-rw-r--r--Tests/RunCMake/CMP0129/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0129/CXX.cmake8
-rw-r--r--Tests/RunCMake/CMP0129/CompareCompilerVersion.cmake41
-rw-r--r--Tests/RunCMake/CMP0129/Fortran.cmake15
-rw-r--r--Tests/RunCMake/CMP0129/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CPack/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/RunCMake.cmake3
-rw-r--r--Tests/RunCMake/try_compile/RunCMakeTest.cmake4
-rw-r--r--Tests/SetLang/CMakeLists.txt3
-rw-r--r--Tests/TryCompile/CMakeLists.txt3
35 files changed, 287 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e63f44c71..1fe847f9ae 100644
--- a/CMakeLists.txt
+++ b/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)
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 3df4f9fa79..0939a82b27 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/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
=================================
diff --git a/Help/policy/CMP0129.rst b/Help/policy/CMP0129.rst
new file mode 100644
index 0000000000..31a26e5555
--- /dev/null
+++ b/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
diff --git a/Help/release/dev/lcc-compiler.rst b/Help/release/dev/lcc-compiler.rst
index 59deef822d..719611dc7e 100644
--- a/Help/release/dev/lcc-compiler.rst
+++ b/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`.
diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
index 02316682ed..8c84f9115c 100644
--- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst
+++ b/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
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 6437be0cf2..ca90032113 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/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}"
diff --git a/Modules/Compiler/LCC-C-DetermineCompiler.cmake b/Modules/Compiler/LCC-C-DetermineCompiler.cmake
index 6c7a08f9b9..2ce92fe3ae 100644
--- a/Modules/Compiler/LCC-C-DetermineCompiler.cmake
+++ b/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")
diff --git a/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake b/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake
index 6c7a08f9b9..2ce92fe3ae 100644
--- a/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake
+++ b/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")
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6dabf63744..d5207d83af 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/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(
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index ce0411761c..99e2eb6bbc 100644
--- a/Source/cmPolicies.h
+++ b/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) \
diff --git a/Tests/Assembler/CMakeLists.txt b/Tests/Assembler/CMakeLists.txt
index 65207d8370..1b7e57d28c 100644
--- a/Tests/Assembler/CMakeLists.txt
+++ b/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)
diff --git a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt
index 6e5160b3e7..a6b3ffe101 100644
--- a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt
+++ b/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)
diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
index 362133e39c..869a941568 100644
--- a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt
+++ b/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
diff --git a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
index 07ec4e32db..52080bdc97 100644
--- a/Tests/CMakeCommands/target_link_libraries/CMakeLists.txt
+++ b/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
diff --git a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt b/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt
index 9c203c717a..c7e3105045 100644
--- a/Tests/CMakeOnly/CheckCXXCompilerFlag/CMakeLists.txt
+++ b/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)")
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt
index e6db5b7d22..0fbfb83716 100644
--- a/Tests/CompileOptions/CMakeLists.txt
+++ b/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)
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt
index 3a490c20d1..a79efd0961 100644
--- a/Tests/ExportImport/Export/CMakeLists.txt
+++ b/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
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 006313091f..e6dcd65f97 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/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.
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index 69899e96c7..cdc08c4d70 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/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 ")
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index dd29fe5f5f..5be1e97e2f 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/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
diff --git a/Tests/LinkStatic/CMakeLists.txt b/Tests/LinkStatic/CMakeLists.txt
index 60a270bde6..ad3b11169a 100644
--- a/Tests/LinkStatic/CMakeLists.txt
+++ b/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")
diff --git a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt b/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
index 694073a0d1..8898f3bcc4 100644
--- a/Tests/Module/WriteCompilerDetectionHeader/CMakeLists.txt
+++ b/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)
diff --git a/Tests/RunCMake/CMP0129/C.cmake b/Tests/RunCMake/CMP0129/C.cmake
new file mode 100644
index 0000000000..e9ebe90e14
--- /dev/null
+++ b/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)
diff --git a/Tests/RunCMake/CMP0129/CMakeLists.txt b/Tests/RunCMake/CMP0129/CMakeLists.txt
new file mode 100644
index 0000000000..d8200fca0a
--- /dev/null
+++ b/Tests/RunCMake/CMP0129/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0129/CXX.cmake b/Tests/RunCMake/CMP0129/CXX.cmake
new file mode 100644
index 0000000000..ffb81b84c5
--- /dev/null
+++ b/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)
diff --git a/Tests/RunCMake/CMP0129/CompareCompilerVersion.cmake b/Tests/RunCMake/CMP0129/CompareCompilerVersion.cmake
new file mode 100644
index 0000000000..e4ba19173e
--- /dev/null
+++ b/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()
diff --git a/Tests/RunCMake/CMP0129/Fortran.cmake b/Tests/RunCMake/CMP0129/Fortran.cmake
new file mode 100644
index 0000000000..abaca7e19a
--- /dev/null
+++ b/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)
diff --git a/Tests/RunCMake/CMP0129/RunCMakeTest.cmake b/Tests/RunCMake/CMP0129/RunCMakeTest.cmake
new file mode 100644
index 0000000000..1b0e11bca2
--- /dev/null
+++ b/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()
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index c87c1b6f21..ed599f0d20 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/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()
diff --git a/Tests/RunCMake/CPack/CMakeLists.txt b/Tests/RunCMake/CPack/CMakeLists.txt
index 1b3dbb2282..c81b34ecd6 100644
--- a/Tests/RunCMake/CPack/CMakeLists.txt
+++ b/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)
diff --git a/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt b/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt
index 0421e28036..30cb9aebf0 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt
+++ b/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)
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 3363a579e0..6f79b78e6c 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/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()
diff --git a/Tests/RunCMake/try_compile/RunCMakeTest.cmake b/Tests/RunCMake/try_compile/RunCMakeTest.cmake
index 28a990d51d..4f2cc5c37a 100644
--- a/Tests/RunCMake/try_compile/RunCMakeTest.cmake
+++ b/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()
diff --git a/Tests/SetLang/CMakeLists.txt b/Tests/SetLang/CMakeLists.txt
index 5b2eb195d3..14e9d6e602 100644
--- a/Tests/SetLang/CMakeLists.txt
+++ b/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)
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index e35e0d31fe..b1b9d57090 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/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)