diff --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt --- a/libcxx/test/CMakeLists.txt +++ b/libcxx/test/CMakeLists.txt @@ -46,6 +46,30 @@ message(FATAL_ERROR "Expected LIBCXX_TEST_DEPS to be defined") endif() +if (MSVC) + # Shared code for initializing some parameters used by all + # llvm-libc++-*-clangcl.cfg.in test configs. + set(dbg_include "") + + if (NOT CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES "DLL$") + set(crt_lib "msvcrt") + set(cxx_lib "msvcprt") + else() + set(crt_lib "libcmt") + set(cxx_lib "libcpmt") + endif() + + if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") + set(dbg_include " -include set_windows_crt_report_mode.h") + set(crt_lib "${crt_lib}d") + set(cxx_lib "${cxx_lib}d") + endif() + + serialize_lit_param(dbg_include "\"${dbg_include}\"") + serialize_lit_param(crt_lib "\"${crt_lib}\"") + serialize_lit_param(cxx_lib "\"${cxx_lib}\"") +endif() + if (LIBCXX_INCLUDE_TESTS) include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuite diff --git a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in --- a/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in +++ b/libcxx/test/configs/llvm-libc++-shared-clangcl.cfg.in @@ -3,27 +3,12 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') -dbg_include = '' -runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@' - -if runtime_library == '' or runtime_library.endswith('DLL'): - crt_lib = 'msvcrt' - cxx_lib = 'msvcprt' -else: - crt_lib = 'libcmt' - cxx_lib = 'libcpmt' - -if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG': - dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h' - crt_lib += 'd' - cxx_lib += 'd' - config.substitutions.append(('%{flags}', '--driver-mode=g++')) config.substitutions.append(('%{compile_flags}', - '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + dbg_include + '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include )) config.substitutions.append(('%{link_flags}', - '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib) + '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib) )) config.substitutions.append(('%{exec}', '%{executor} --execdir %T --prepend_env PATH=%{lib} -- ' diff --git a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in --- a/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in +++ b/libcxx/test/configs/llvm-libc++-shared-no-vcruntime-clangcl.cfg.in @@ -4,27 +4,12 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') -dbg_include = '' -runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@' - -if runtime_library == '' or runtime_library.endswith('DLL'): - crt_lib = 'msvcrt' - cxx_lib = 'msvcprt' -else: - crt_lib = 'libcmt' - cxx_lib = 'libcpmt' - -if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG': - dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h' - crt_lib += 'd' - cxx_lib += 'd' - config.substitutions.append(('%{flags}', '--driver-mode=g++')) config.substitutions.append(('%{compile_flags}', - '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + dbg_include + '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX -D_HAS_EXCEPTIONS=0' + config.dbg_include )) config.substitutions.append(('%{link_flags}', - '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib) + '-nostdlib -L %%{lib} -lc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib) )) config.substitutions.append(('%{exec}', '%{executor} --execdir %T --prepend_env PATH=%{lib} -- ' diff --git a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in --- a/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in +++ b/libcxx/test/configs/llvm-libc++-static-clangcl.cfg.in @@ -3,27 +3,12 @@ lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg') -dbg_include = '' -runtime_library = '@CMAKE_MSVC_RUNTIME_LIBRARY@' - -if runtime_library == '' or runtime_library.endswith('DLL'): - crt_lib = 'msvcrt' - cxx_lib = 'msvcprt' -else: - crt_lib = 'libcmt' - cxx_lib = 'libcpmt' - -if '@uppercase_CMAKE_BUILD_TYPE@' == 'DEBUG': - dbg_include = ' -D_DEBUG -include set_windows_crt_report_mode.h' - crt_lib += 'd' - cxx_lib += 'd' - config.substitutions.append(('%{flags}', '--driver-mode=g++')) config.substitutions.append(('%{compile_flags}', - '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + dbg_include + '-nostdinc++ -I %{include} -I %{target-include} -I %{libcxx}/test/support -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_STDIO_ISO_WIDE_SPECIFIERS -DNOMINMAX' + config.dbg_include )) config.substitutions.append(('%{link_flags}', - '-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (crt_lib, cxx_lib) + '-nostdlib -L %%{lib} -llibc++ -l%s -l%s -loldnames' % (config.crt_lib, config.cxx_lib) )) config.substitutions.append(('%{exec}', '%{executor} --execdir %T -- '