Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 0e4fcac

Browse files
committed
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
1 parent ab37a95 commit 0e4fcac

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

CMakeLists.txt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,26 @@ set(LLVM_USE_SANITIZER "" CACHE STRING
343343
option(LLVM_USE_SPLIT_DWARF
344344
"Use -gsplit-dwarf when compiling llvm." OFF)
345345

346-
option(WITH_POLLY "Build LLVM with Polly" ON)
347-
option(LINK_POLLY_INTO_TOOLS "Static link Polly into tools" ON)
346+
option(LLVM_POLLY_LINK_INTO_TOOLS "Statically link Polly into tools (if available)" ON)
347+
option(LLVM_POLLY_BUILD "Build LLVM with Polly" ON)
348+
349+
if (EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
350+
set(POLLY_IN_TREE TRUE)
351+
else()
352+
set(POLLY_IN_TREE FALSE)
353+
endif()
354+
355+
if (LLVM_POLLY_BUILD AND POLLY_IN_TREE)
356+
set(WITH_POLLY ON)
357+
else()
358+
set(WITH_POLLY OFF)
359+
endif()
360+
361+
if (LLVM_POLLY_LINK_INTO_TOOLS AND WITH_POLLY)
362+
set(LINK_POLLY_INTO_TOOLS ON)
363+
else()
364+
set(LINK_POLLY_INTO_TOOLS OFF)
365+
endif()
348366

349367
# Define an option controlling whether we should build for 32-bit on 64-bit
350368
# platforms, where supported.
@@ -395,16 +413,6 @@ option (LLVM_ENABLE_SPHINX "Use Sphinx to generate llvm documentation." OFF)
395413
option (LLVM_BUILD_EXTERNAL_COMPILER_RT
396414
"Build compiler-rt as an external project." OFF)
397415

398-
if(WITH_POLLY)
399-
if(NOT EXISTS ${LLVM_MAIN_SRC_DIR}/tools/polly/CMakeLists.txt)
400-
set(WITH_POLLY OFF)
401-
endif()
402-
endif(WITH_POLLY)
403-
404-
if (NOT WITH_POLLY)
405-
set(LINK_POLLY_INTO_TOOLS OFF)
406-
endif (NOT WITH_POLLY)
407-
408416
# You can configure which libraries from LLVM you want to include in the
409417
# shared library by setting LLVM_DYLIB_COMPONENTS to a semi-colon delimited
410418
# list of LLVM components. All component names handled by llvm-config are valid.

0 commit comments

Comments
 (0)