diff options
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake | 37 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake | 5 | ||||
-rw-r--r-- | Tests/RunCMake/MSVCRuntimeLibrary/empty.c | 0 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake | 34 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/RuntimeLibrary.cmake | 16 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/empty.c | 0 | ||||
-rw-r--r-- | Tests/RunCMake/VS10Project/empty.cxx | 0 |
15 files changed, 108 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 68411d6..a8dcb4b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -195,6 +195,9 @@ add_RunCMake_test(LinkStatic) if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|XL|XLClang)$") add_RunCMake_test(MetaCompileFeatures) endif() +if(MSVC) + add_RunCMake_test(MSVCRuntimeLibrary) +endif() add_RunCMake_test(ObjectLibrary) add_RunCMake_test(ParseImplicitIncludeInfo) if(UNIX AND CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG AND CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF") diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt new file mode 100644 index 0000000..803058d --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error in CMakeLists.txt: + MSVC_RUNTIME_LIBRARY value 'BogusValue' not known for this C compiler.$ diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake new file mode 100644 index 0000000..c3ea2fd --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0091 NEW) +include(CMP0091-common.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake new file mode 100644 index 0000000..734cc9f --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0091 OLD) +include(CMP0091-common.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake new file mode 100644 index 0000000..26f86a0 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-WARN.cmake @@ -0,0 +1,2 @@ + +include(CMP0091-common.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake new file mode 100644 index 0000000..7827d2a --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMP0091-common.cmake @@ -0,0 +1,37 @@ +enable_language(C) + +cmake_policy(GET CMP0091 cmp0091) +if(cmp0091 STREQUAL "NEW") + if(NOT CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + message(SEND_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT not set under NEW behavior") + endif() +else() + if(CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT) + message(SEND_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT is set under OLD behavior") + endif() +endif() + +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + if(CMAKE_C_FLAGS_DEBUG MATCHES "[/-]MDd( |$)") + set(have_MDd 1) + else() + set(have_MDd 0) + endif() + if(CMAKE_C_FLAGS_RELEASE MATCHES "[/-]MD( |$)") + set(have_MD 1) + else() + set(have_MD 0) + endif() + if(cmp0091 STREQUAL "NEW") + if(have_MDd OR have_MD) + message(SEND_ERROR "Have a -MD* flag under NEW behavior.") + endif() + else() + if(NOT (have_MDd AND have_MD)) + message(SEND_ERROR "Do not have -MD* flags under OLD behavior.") + endif() + endif() +endif() + +set(CMAKE_MSVC_RUNTIME_LIBRARY BogusValue) +add_library(foo empty.c) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt b/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt new file mode 100644 index 0000000..3e470a2 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.14) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake b/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake new file mode 100644 index 0000000..fad18da --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/RunCMakeTest.cmake @@ -0,0 +1,5 @@ +include(RunCMake) + +run_cmake(CMP0091-WARN) +run_cmake(CMP0091-OLD) +run_cmake(CMP0091-NEW) diff --git a/Tests/RunCMake/MSVCRuntimeLibrary/empty.c b/Tests/RunCMake/MSVCRuntimeLibrary/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/MSVCRuntimeLibrary/empty.c diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index 219e529..0ac589d 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -2,6 +2,7 @@ include(RunCMake) run_cmake(VsCSharpCompilerOpts) run_cmake(ExplicitCMakeLists) +run_cmake(RuntimeLibrary) run_cmake(SourceGroupCMakeLists) run_cmake(VsConfigurationType) diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake new file mode 100644 index 0000000..6b43d47 --- /dev/null +++ b/Tests/RunCMake/VS10Project/RuntimeLibrary-check.cmake @@ -0,0 +1,34 @@ +macro(RuntimeLibrary_check tgt rtl_expect) + set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj") + if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.") + return() + endif() + + set(HAVE_Runtimelibrary 0) + + file(STRINGS "${vcProjectFile}" lines) + foreach(line IN LISTS lines) + if(line MATCHES "^ *<RuntimeLibrary>([^<>]+)</RuntimeLibrary>") + set(rtl_actual "${CMAKE_MATCH_1}") + if(NOT "${rtl_actual}" STREQUAL "${rtl_expect}") + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has RuntimeLibrary '${rtl_actual}', not '${rtl_expect}'.") + return() + endif() + set(HAVE_Runtimelibrary 1) + break() + endif() + endforeach() + + if(NOT HAVE_Runtimelibrary) + set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a RuntimeLibrary field.") + return() + endif() +endmacro() + +RuntimeLibrary_check(default-C MultiThreadedDebugDLL) +RuntimeLibrary_check(default-CXX MultiThreadedDebugDLL) +RuntimeLibrary_check(MTd-C MultiThreadedDebug) +RuntimeLibrary_check(MTd-CXX MultiThreadedDebug) +RuntimeLibrary_check(MT-C MultiThreaded) +RuntimeLibrary_check(MT-CXX MultiThreaded) diff --git a/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake new file mode 100644 index 0000000..6c77a25 --- /dev/null +++ b/Tests/RunCMake/VS10Project/RuntimeLibrary.cmake @@ -0,0 +1,16 @@ +set(CMAKE_CONFIGURATION_TYPES Debug) +cmake_policy(SET CMP0091 NEW) +enable_language(C) +enable_language(CXX) + +add_library(default-C empty.c) +add_library(default-CXX empty.cxx) + +set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug") +add_library(MTd-C empty.c) +add_library(MTd-CXX empty.cxx) + +add_library(MT-C empty.c) +set_property(TARGET MT-C PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") +add_library(MT-CXX empty.cxx) +set_property(TARGET MT-CXX PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") diff --git a/Tests/RunCMake/VS10Project/empty.c b/Tests/RunCMake/VS10Project/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/VS10Project/empty.c diff --git a/Tests/RunCMake/VS10Project/empty.cxx b/Tests/RunCMake/VS10Project/empty.cxx new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/VS10Project/empty.cxx |