summaryrefslogtreecommitdiff
path: root/cmake/modules
diff options
context:
space:
mode:
authorShoaib Meenai <smeenai@fb.com>2019-03-26 22:16:53 +0000
committerShoaib Meenai <smeenai@fb.com>2019-03-26 22:16:53 +0000
commitf17219973cd3249977f260d834bc92ca9c16ee3b (patch)
treeffe7eec09683d31c9655cd1979813edd06a1b6f5 /cmake/modules
parent1eeae75f3fc8e59305cc7f738b11a0976cb4f0bc (diff)
downloadclang-f17219973cd3249977f260d834bc92ca9c16ee3b.tar.gz
[cmake] Reset variable before using it
A bunch of macros use the same variable name, and since CMake macros don't get their own scope, the value persists across macro invocations, and we can end up exporting targets which shouldn't be exported. Clear the variable before each use to avoid this. Converting these macros to functions would also help, since it would avoid the variable leaking into its parent scope, and that's something I plan to follow up with. It won't fully address the problem, however, since functions still inherit variables from their parent scopes, so if someone in the parent scope just happened to use the same variable name we'd still have the same issue. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@357036 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/modules')
-rw-r--r--cmake/modules/AddClang.cmake3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmake/modules/AddClang.cmake b/cmake/modules/AddClang.cmake
index 76ff6b1f15..18bac7172b 100644
--- a/cmake/modules/AddClang.cmake
+++ b/cmake/modules/AddClang.cmake
@@ -89,7 +89,7 @@ macro(add_clang_library name)
target_link_libraries(${name} INTERFACE ${LLVM_COMMON_LIBS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "libclang")
-
+ set(export_to_clangtargets)
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
"clang-libraries" IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
@@ -137,6 +137,7 @@ macro(add_clang_tool name)
add_dependencies(${name} clang-resource-headers)
if (CLANG_BUILD_TOOLS)
+ set(export_to_clangtargets)
if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
NOT LLVM_DISTRIBUTION_COMPONENTS)
set(export_to_clangtargets EXPORT ClangTargets)