Re: [RFC] Handling cmake policies

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: [RFC] Handling cmake policies

Jon Chesterfield via cfe-dev
+cfe-dev since this change would affect all projects

On Wed, Jan 24, 2018 at 8:30 PM, Don Hinton <[hidden email]> wrote:
Currently, cmake policies are manually maintained by each project.  This is done via a set of `cmake_policy()` commands following the initial `cmake_minimum_required()` command at the top of each CMakeLists.txt project file.  

Somewhat surprisingly, these sets are local to each project and independent of each other -- even for in-tree builds containing multiple sub-projects.  This is because cmake policies are reset whenever `cmake_minimum_required()` is called, which is the first command in each of our CMakeLists.txt project files.  

In order to solve this problem, as well as improve maintainabilityI'd like to propose the following:

* For all projects except llvm, move `cmake_minimum_required()` inside the standalone build if-branch, i.e., `if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)`, at the top of the CMakeLists.txt project file.  This will prevent unnecessary calls `cmake_minimum_required()` for in-tree builds, and allow all sub-projects to use the same policies set by llvm.

* Move all `cmake_policy()` commands out of llvm/CMakeLists.txt and into a separate file, e.g., AddLLVM.cmake, which is always included in each project.  This will guarantee all projects use the same set of policies even when built as a standalone or external project, e.g., runtimes.

Sub-projects can still override policies as needed by setting them after including AddLLVM.cmake, or by using `cmake_policy(PUSH|POP)` for local changes.



_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev