diff options
35 files changed, 287 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 1e63f44..1fe847f 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 3df4f9f..0939a82 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 0000000..31a26e5 --- /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 59deef8..719611d 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 0231668..8c84f91 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 6437be0..ca90032 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 6c7a08f..2ce92fe 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 6c7a08f..2ce92fe 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 6dabf63..d5207d8 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 ce04117..99e2eb6 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 65207d8..1b7e57d 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 6e5160b..a6b3ffe 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 362133e..869a941 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 07ec4e3..52080bd 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 9c203c7..c7e3105 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 e6db5b7..0fbfb83 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 3a490c2..a79efd0 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 0063130..e6dcd65 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 69899e9..cdc08c4 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 dd29fe5..5be1e97 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 60a270b..ad3b111 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 694073a..8898f3b 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 0000000..e9ebe90 --- /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 0000000..d8200fc --- /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 0000000..ffb81b8 --- /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 0000000..e4ba191 --- /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 0000000..abaca7e --- /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 0000000..1b0e11b --- /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 c87c1b6..ed599f0 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 1b3dbb2..c81b34e 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 0421e28..30cb9ae 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 3363a57..6f79b78 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 28a990d..4f2cc5c 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 5b2eb19..14e9d6e 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 e35e0d3..b1b9d57 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) |