diff options
author | makise-homura <akemi_homura@kurisa.ch> | 2021-10-19 18:43:45 (GMT) |
---|---|---|
committer | makise-homura <akemi_homura@kurisa.ch> | 2021-10-21 14:24:22 (GMT) |
commit | 3958ed878f2365fd1af004341d45dac7f4e94afb (patch) | |
tree | 0192b68ccf8fc248efadb1bf91deddc1927bf434 /Tests/RunCMake | |
parent | 52ea22ca65d86627e9ab571f2a87d4a952a7d85e (diff) | |
download | CMake-3958ed878f2365fd1af004341d45dac7f4e94afb.zip CMake-3958ed878f2365fd1af004341d45dac7f4e94afb.tar.gz CMake-3958ed878f2365fd1af004341d45dac7f4e94afb.tar.bz2 |
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.
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/CMP0129/C.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0129/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0129/CXX.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0129/CompareCompilerVersion.cmake | 41 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0129/Fortran.cmake | 15 | ||||
-rw-r--r-- | Tests/RunCMake/CMP0129/RunCMakeTest.cmake | 8 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CheckCompilerFlag/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/RunCMake.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/try_compile/RunCMakeTest.cmake | 4 |
11 files changed, 100 insertions, 2 deletions
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() |