summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Grosser <tobias@grosser.es>2016-05-04 20:04:40 +0000
committerTobias Grosser <tobias@grosser.es>2016-05-04 20:04:40 +0000
commit0e4fcac9c647620f8d01710344aa983425517758 (patch)
treec1c6e96a9551c94dd48888a9779e7153e164e329
parentab37a95312b97a44be043361fcf24e165b139bb5 (diff)
cmake: Prefix Polly options with LLVM_ to avoid variable shadowing
Summary: Before this change certain Polly variables have been used both as user-facing CACHED cmake variables as well as uncached internal variables. Even though this seems to have worked OK in practice, the behavior only worked due to one variable shadowing the other. This behavior has been found confusing. To make the use of cmake variables more clear we now prefix the cached, user facing variables with LLVM_ as it is common habit for LLVM options and also moved the _POLLY_ term to the beginning to ensure related options are sorted after each other. The variables that control the behavior of LLVM/Polly are then set by forwarding the values set in the user facing option variables. As a result, Polly is now enabled with LLVM_POLLY_BUILD instead of BUILD_POLLY and the linking behavior of Polly is controlled with LLVM_POLLY_LINK_INTO_TOOLS instead of LINK_POLLY_INTO_TOOLS. Reviewers: bogner, Meinersbur Subscribers: pollydev, llvm-commits Differential Revision: http://reviews.llvm.org/D19907 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@268537 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--CMakeLists.txt32
1 files changed, 20 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7d30166fb32..4ca0d67f31b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -343,8 +343,26 @@ set(LLVM_USE_SANITIZER "" CACHE STRING
option(LLVM_USE_SPLIT_DWARF
"Use -gsplit-dwarf when compiling llvm." OFF)
-option(WITH_POLLY "Build LLVM with Polly" ON)
-option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" ON)
+option(LLVM_POLLY_LINK_INTO_TOOLS "Statically link Polly into tools (if available)" ON)
+option(LLVM_POLLY_BUILD "Build LLVM with Polly" ON)
+
+if (EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
+ set(POLLY_IN_TREE TRUE)
+else()
+ set(POLLY_IN_TREE FALSE)
+endif()
+
+if (LLVM_POLLY_BUILD AND POLLY_IN_TREE)
+ set(WITH_POLLY ON)
+else()
+ set(WITH_POLLY OFF)
+endif()
+
+if (LLVM_POLLY_LINK_INTO_TOOLS AND WITH_POLLY)
+ set(LINK_POLLY_INTO_TOOLS ON)
+else()
+ set(LINK_POLLY_INTO_TOOLS OFF)
+endif()
# Define an option controlling whether we should build for 32-bit on 64-bit
# platforms, where supported.
@@ -395,16 +413,6 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
option (LLVM_BUILD_EXTERNAL_COMPILER_RT
"Build compiler-rt as an external project." OFF)
-if(WITH_POLLY)
- if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
- set(WITH_POLLY OFF)
- endif()
-endif(WITH_POLLY)
-
-if (NOT WITH_POLLY)
- set(LINK_POLLY_INTO_TOOLS OFF)
-endif (NOT WITH_POLLY)
-
# You can configure which libraries from LLVM you want to include in the
# shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited
# list of LLVM components. All component names handled by llvm-config are valid.