diff options
-rw-r--r-- | CMakeLists.txt | 13 | ||||
-rw-r--r-- | cmake/Modules/AddCompilerRT.cmake | 4 | ||||
-rw-r--r-- | cmake/Modules/CompilerRTCompile.cmake | 4 |
3 files changed, 17 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e1a7a1f04..87e1fadb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,8 +57,17 @@ if (NOT COMPILER_RT_STANDALONE_BUILD) ${LLVM_INCLUDE_TESTS}) option(COMPILER_RT_ENABLE_WERROR "Fail and stop if warning is triggered" ${LLVM_ENABLE_WERROR}) - # Use just-built Clang to compile/link tests. - set(COMPILER_RT_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) + # Use just-built Clang to compile/link tests on all platforms, except for + # Windows where we need to use clang-cl instead. + if(NOT MSVC) + set(COMPILER_RT_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang) + set(COMPILER_RT_TEST_COMPILER_EXE "-o") + set(COMPILER_RT_TEST_COMPILER_OBJ "-o") + else() + set(COMPILER_RT_TEST_COMPILER ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl.exe) + set(COMPILER_RT_TEST_COMPILER_EXE "-Fe") + set(COMPILER_RT_TEST_COMPILER_OBJ "-Fo") + endif() else() # Take output dir and install path from the user. set(COMPILER_RT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index ba22927d7..5b3b740bb 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -137,7 +137,9 @@ macro(add_compiler_rt_test test_suite test_name) list(APPEND TEST_DEPS clang) endif() add_custom_target(${test_name} - COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS} -o "${output_bin}" + # MSVS CL doesn't allow a space between -Fe and the output file name. + COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS} + ${COMPILER_RT_TEST_COMPILER_EXE}"${output_bin}" ${TEST_LINK_FLAGS} DEPENDS ${TEST_DEPS}) # Make the test suite depend on the binary. diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake index b3482e9ce..4885c82e7 100644 --- a/cmake/Modules/CompilerRTCompile.cmake +++ b/cmake/Modules/CompilerRTCompile.cmake @@ -23,7 +23,9 @@ macro(clang_compile object_file source) set(compile_flags ${global_flags} ${SOURCE_CFLAGS}) add_custom_command( OUTPUT ${object_file} - COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c -o "${object_file}" + # MSVS CL doesn't allow a space between -Fo and the object file name. + COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c + ${COMPILER_RT_TEST_COMPILER_OBJ}"${object_file}" ${source_rpath} MAIN_DEPENDENCY ${source} DEPENDS ${SOURCE_DEPS}) |