summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authormakise-homura <akemi_homura@kurisa.ch>2021-10-19 18:43:45 (GMT)
committermakise-homura <akemi_homura@kurisa.ch>2021-10-21 14:24:22 (GMT)
commit3958ed878f2365fd1af004341d45dac7f4e94afb (patch)
tree0192b68ccf8fc248efadb1bf91deddc1927bf434 /Tests
parent52ea22ca65d86627e9ab571f2a87d4a952a7d85e (diff)
downloadCMake-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')
-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
25 files changed, 147 insertions, 3 deletions
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)