diff options
author | NAKAMURA Takumi <geek4civic@gmail.com> | 2017-06-17 03:19:08 +0000 |
---|---|---|
committer | NAKAMURA Takumi <geek4civic@gmail.com> | 2017-06-17 03:19:08 +0000 |
commit | b903fddc562ccc622cabc4f08f5df2af90ceb251 (patch) | |
tree | 321e5dba513b5de40c388a953611abf26e653670 /cmake | |
parent | 91d2a849ddaeed7399cfb61d07d80c2d492ec02a (diff) |
[CMake] Introduce LLVM_TARGET_TRIPLE_ENV as an option to override LLVM_DEFAULT_TARGET_TRIPLE at runtime.
No behavior is changed if LLVM_TARGET_TRIPLE_ENV is blank or undefined.
If LLVM_TARGET_TRIPLE_ENV is "TEST_TARGET_TRIPLE" and $TEST_TARGET_TRIPLE is not blank,
llvm::sys::getDefaultTargetTriple() returns $TEST_TARGET_TRIPLE.
Lit resets config.target_triple and config.environment[LLVM_TARGET_TRIPLE_ENV] to change the default target.
Without changing LLVM_DEFAULT_TARGET_TRIPLE nor rebuilding, lit can be run;
TEST_TARGET_TRIPLE=i686-pc-win32 bin/llvm-lit -sv path/to/test/
TEST_TARGET_TRIPLE=i686-pc-win32 ninja check-clang-tools
Differential Revision: https://reviews.llvm.org/D33662
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@305632 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/AddLLVM.cmake | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/cmake/modules/AddLLVM.cmake b/cmake/modules/AddLLVM.cmake index e011bb402757..2b54bdbf2900 100644 --- a/cmake/modules/AddLLVM.cmake +++ b/cmake/modules/AddLLVM.cmake @@ -1133,6 +1133,19 @@ function(configure_lit_site_cfg input output) set(LIT_SITE_CFG_IN_HEADER "## Autogenerated from ${input}\n## Do not edit!") + # Override config_target_triple (and the env) + if(LLVM_TARGET_TRIPLE_ENV) + # This is expanded into the heading. + string(CONCAT LIT_SITE_CFG_IN_HEADER "${LIT_SITE_CFG_IN_HEADER}\n\n" + "import os\n" + "target_env = \"${LLVM_TARGET_TRIPLE_ENV}\"\n" + "config.target_triple = config.environment[target_env] = os.environ.get(target_env, \"${TARGET_TRIPLE}\")\n" + ) + + # This is expanded to; config.target_triple = ""+config.target_triple+"" + set(TARGET_TRIPLE "\"+config.target_triple+\"") + endif() + configure_file(${input} ${output} @ONLY) endfunction() |