[Flang] Multi-config CMake output paths in standalone builds (#208690)

When using a multi-config generator with CMake (such as "Ninja
Multi-Config" or any Visual Studio generator), the output path must be
specific to each config by having it include `${CMAKE_CFG_INTDIR}`.
`CMAKE_CFG_INTDIR` will just be `.` in single-config generators. Use the
same path as used by LLVM:
cd662a7c4f/llvm/CMakeLists.txt (L562-L563)

`LLVM_LIBDIR_SUFFIX` was seemingly forgotten in one of the paths.

This is not complete support (neither has LLVM). More paths would need
to be config-specific. In particular, `check-flang` does not work, but
at least one can build the executables.
This commit is contained in:
Michael Kruse 2026-07-13 16:29:34 +02:00 committed by GitHub
parent 695238ffaa
commit c4cb2c0e76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -210,11 +210,11 @@ if (FLANG_STANDALONE_BUILD)
link_directories("${LLVM_LIBRARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
set(LIT_ARGS_DEFAULT "-sv")
if (MSVC OR XCODE)
@ -294,8 +294,8 @@ include_directories(SYSTEM ${CLANG_INCLUDE_DIR})
# tco tool and FIR lib output directories
if(FLANG_STANDALONE_BUILD)
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
endif()
# Always build tco tool
set(LLVM_BUILD_TOOLS ON)