This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Fix cross-compiling with LLVM as CMake subproject
ClosedPublic

Authored by Flakebi on Apr 27 2020, 3:44 AM.

Details

Summary

When embedding LLVM as a CMake subproject, using cross-compiling does
not work at the moment. This also affects -DLLVM_OPTIMIZED_TABLEGEN=1,
which uses the same CMake infrastructure.

This patch replaces global CMake variables with the current version,
which allows cross-compilation to work in a subproject.

CMAKE_BINARY_DIR -> CMAKE_CURRENT_BINARY_DIR
CMAKE_SOURCE_DIR -> CMAKE_CURRENT_SOURCE_DIR
CMAKE_PROJECT_NAME -> PROJECT_NAME

Diff Detail

Event Timeline

Flakebi created this revision.Apr 27 2020, 3:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 27 2020, 3:44 AM
nhaehnle accepted this revision.Apr 30 2020, 6:40 AM

I'm no CMake expert, but this seems pretty plausible to me. LGTM -- though you'll definitely want to keep an eye out for bot failures.

This revision is now accepted and ready to land.Apr 30 2020, 6:40 AM
This revision was automatically updated to reflect the committed changes.