This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Fix source path generation for install in multi-config (MSBuild)
Needs RevisionPublic

Authored by risa2000 on Jul 25 2019, 3:06 AM.

Details

Summary

The folder expansion in install scripts created by CMake for "Visual Studio" generator, which uses multi config builds (MSBuild), requires using "expression generator", in order to correctly expand the target paths.

This is a mirror of the bug (https://bugs.llvm.org/show_bug.cgi?id=41030), which comes also with a lengthy description and some reasoning for the change.

The short version is:

The current scripts (throughout the LLVM project) use extensively CMake variable ${Configuration} to identify the current build type (e.g. Debug, Release, etc.), and expect that this variable gets expanded correctly when the runtime script is generated. This approach (in general) does not work for multi-config generators (e.g. MSBuild), which need all the possible build type script created in advance.

Some CMake scripts are working around this by using "specialized" (by build type) target properties (e.g. ARCHIVE_OUTPUT_DIRECTORY_<CONFIG>) and basically do the expansion manually, some do not do that and those fail. This patch provides a fix for install path generations and also shows, how this topic should be handled in LLVM in the broader scope.

Diff Detail

Event Timeline

risa2000 created this revision.Jul 25 2019, 3:06 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJul 25 2019, 3:06 AM
Herald added subscribers: llvm-commits, Restricted Project, cfe-commits, mgorny. · View Herald Transcript

LGTM, @beanz and @smeenai do you have any further comments?

phosek accepted this revision.Jul 26 2019, 12:50 PM
This revision is now accepted and ready to land.Jul 26 2019, 12:50 PM
beanz requested changes to this revision.Jul 26 2019, 2:09 PM
beanz added inline comments.
clang/lib/Headers/CMakeLists.txt
190

I think this will break Xcode

This revision now requires changes to proceed.Jul 26 2019, 2:09 PM
risa2000 added inline comments.Jul 27 2019, 1:33 PM
clang/lib/Headers/CMakeLists.txt
190

I guess I put it in since it seemed to be already used around:

$ grep -r "if(CMAKE_CONFIGURATION_TYPES)" *
compiler-rt/cmake/Modules/AddCompilerRT.cmake:  if(CMAKE_CONFIGURATION_TYPES)
compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake:    if(CMAKE_CONFIGURATION_TYPES)
compiler-rt/CMakeLists.txt:if(CMAKE_CONFIGURATION_TYPES)
lldb/utils/lldb-dotest/CMakeLists.txt:  if(CMAKE_CONFIGURATION_TYPES)
llvm/cmake/modules/AddLLVM.cmake:    if(CMAKE_CONFIGURATION_TYPES)
llvm/cmake/modules/AddLLVM.cmake:    if(CMAKE_CONFIGURATION_TYPES)
llvm/cmake/modules/CrossCompile.cmake:  if(CMAKE_CONFIGURATION_TYPES)

but technically, the generator expression should work equally for single and multi-config generators, so the condition is not necessary. What exactly will break Xcode?

I wonder if someone could explain what happened and if this has been dropped because of the comment from @beanz? I am not using XCode so I cannot comment on its requirements nor fix the code for it.

Someone has subscribed to this bug on https://bugs.llvm.org/show_bug.cgi?id=41030 so I got an urge to check on the bug again and possibly get to some conclusion.