diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/WatcomRuntimeLibrary/CMakeLists.txt | 49 | ||||
-rw-r--r-- | Tests/WatcomRuntimeLibrary/verify.c | 1 | ||||
-rw-r--r-- | Tests/WatcomRuntimeLibrary/verify.cxx | 1 | ||||
-rw-r--r-- | Tests/WatcomRuntimeLibrary/verify.h | 31 |
5 files changed, 86 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9a1cf69..9cee144 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2077,6 +2077,10 @@ if(BUILD_TESTING) ADD_TEST_MACRO(ModuleDefinition example_exe) endif() + if (CMAKE_C_COMPILER_ID MATCHES "Watcom" AND WIN32) + ADD_TEST_MACRO(WatcomRuntimeLibrary) + endif() + ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables) if("${CMAKE_GENERATOR}" MATCHES "Makefile" OR diff --git a/Tests/WatcomRuntimeLibrary/CMakeLists.txt b/Tests/WatcomRuntimeLibrary/CMakeLists.txt new file mode 100644 index 0000000..e8a3edc --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/CMakeLists.txt @@ -0,0 +1,49 @@ +cmake_minimum_required(VERSION 3.23) +cmake_policy(SET CMP0136 NEW) +project(WatcomRuntimeLibrary) + +function(verify_combinations threads lang src) + set(verify_def_MultiThreaded -DVERIFY_MT) + set(verify_def_DLL -DVERIFY_DLL) + foreach(dll "" DLL) + # Construct the name of this runtime library combination. + set(rtl "${threads}${dll}") + + # Test that try_compile builds with this RTL. + set(CMAKE_WATCOM_RUNTIME_LIBRARY "${rtl}") + set(CMAKE_TRY_COMPILE_TARGET_TYPE "STATIC_LIBRARY") + try_compile(${rtl}_COMPILES + ${CMAKE_CURRENT_BINARY_DIR}/try_compile/${rtl} + ${CMAKE_CURRENT_SOURCE_DIR}/${src} + COMPILE_DEFINITIONS ${verify_def_${threads}} ${verify_def_${dll}} + OUTPUT_VARIABLE ${rtl}_OUTPUT + ) + if(${rtl}_COMPILES) + message(STATUS "try_compile with ${rtl} worked") + else() + string(REPLACE "\n" "\n " ${rtl}_OUTPUT " ${${rtl}_OUTPUT}") + message(SEND_ERROR "try_compile with ${rtl} failed:\n${${rtl}_OUTPUT}") + endif() + + # Test that targets build with this RTL. + set(CMAKE_WATCOM_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>") + add_library(${rtl}-${lang} ${src}) + set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE) + target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dll}}) + endforeach() +endfunction() + +function(verify lang src) + add_library(default-${lang} ${src}) + target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL) + + verify_combinations(SingleThreaded ${lang} ${src}) + verify_combinations(MultiThreaded ${lang} ${src}) + + # Test known default behavior when no flag is given. + set(CMAKE_WATCOM_RUNTIME_LIBRARY "") + add_library(empty-${lang} ${src}) +endfunction() + +verify(C verify.c) +verify(CXX verify.cxx) diff --git a/Tests/WatcomRuntimeLibrary/verify.c b/Tests/WatcomRuntimeLibrary/verify.c new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/verify.c @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/WatcomRuntimeLibrary/verify.cxx b/Tests/WatcomRuntimeLibrary/verify.cxx new file mode 100644 index 0000000..741bca6 --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/verify.cxx @@ -0,0 +1 @@ +#include "verify.h" diff --git a/Tests/WatcomRuntimeLibrary/verify.h b/Tests/WatcomRuntimeLibrary/verify.h new file mode 100644 index 0000000..6c67e6d --- /dev/null +++ b/Tests/WatcomRuntimeLibrary/verify.h @@ -0,0 +1,31 @@ +#ifdef VERIFY_DLL +# ifndef _DLL +# error "_DLL not defined by DLL runtime library selection" +# endif +# ifndef __SW_BR +# error "__SW_BR not defined by DLL runtime library selection" +# endif +#else +# ifdef _DLL +# error "_DLL defined by non-DLL runtime library selection" +# endif +# ifdef __SW_BR +# error "__SW_BR defined by non-DLL runtime library selection" +# endif +#endif + +#ifdef VERIFY_MT +# ifndef _MT +# error "_MT not defined by multi-threaded runtime library selection" +# endif +# ifndef __SW_BM +# error "__SW_BM not defined by multi-threaded runtime library selection" +# endif +#else +# ifdef _MT +# error "_MT defined by single-threaded runtime library selection" +# endif +# ifdef __SW_BM +# error "__SW_BM defined by single-threaded runtime library selection" +# endif +#endif |