[llvm] r354060 - [CMake] Fix ability to use LLVM_ENABLE_PROJECTS with LLVM_EXTERNAL_PROJECTS

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Wed May 15 03:28:20 PDT 2019


I just ran into this too, i.e. setting
-DLLVM_ENABLE_PROJECTS="clang;lld", and then using
-DLLVM_EXTERNAL_PROJECTS="my_clang_plugin"
-DLLVM_EXTERNAL_MY_CLANG_PLUGIN_SOURCE_DIR=/somewhere

And the code here now helpfully disables my_clang_plugin :-p

Would something like this work? Or is there some other way?

diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 0164d3eaa..4852c6484 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -141,6 +141,9 @@ if (LLVM_ENABLE_PROJECTS_USED OR NOT
LLVM_ENABLE_PROJECTS STREQUAL "")
         message(FATAL_ERROR "LLVM_ENABLE_PROJECTS requests ${proj}
but directory not found: ${PROJ_DIR}")
       endif()
       set(LLVM_EXTERNAL_${upper_proj}_SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/../${proj}" CACHE STRING "")
+    elseif ("${proj}" IN_LIST LLVM_EXTERNAL_PROJECTS)
+      message(STATUS "${proj} project is enabled")
+      set(SHOULD_ENABLE_PROJECT TRUE)
     else()
       message(STATUS "${proj} project is disabled")
       set(SHOULD_ENABLE_PROJECT FALSE)

On Wed, Feb 20, 2019 at 2:11 AM Shoaib Meenai via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
>
> This fixes the LLVM_EXTERNAL_PROJECTS with LLVM_ENABLE_PROJECTS case but breaks the LLVM_EXTERNAL_PROJECTS without LLVM_ENABLE_PROJECTS case. We iterate over the combination of LLVM_ENABLE_PROJECTS and LLVM_EXTERNAL_PROJECTS, but then we only look up the items from LLVM_ENABLE_PROJECTS in that combined list, so anything that's in LLVM_EXTERNAL_PROJECTS but not in LLVM_ENABLE_PROJECTS (e.g. because it doesn't live side-by-side) gets disabled.
>
>
>
> One option to fix this would be to change the lookup to search in LLVM_EXTERNAL_PROJECTS as well, and then change the LLVM_EXTERNAL_*_SOURCE_DIR setting in this loop to be CACHEd, so that it doesn't override a user's setting. That should keep both cases working. What do you think?
>
>
>
> From: llvm-commits <llvm-commits-bounces at lists.llvm.org> on behalf of Chris Bieneman via llvm-commits <llvm-commits at lists.llvm.org>
> Reply-To: Chris Bieneman <chris.bieneman at me.com>
> Date: Thursday, February 14, 2019 at 2:57 PM
> To: "llvm-commits at lists.llvm.org" <llvm-commits at lists.llvm.org>
> Subject: [llvm] r354060 - [CMake] Fix ability to use LLVM_ENABLE_PROJECTS with LLVM_EXTERNAL_PROJECTS
>
>
>
> Author: cbieneman
>
> Date: Thu Feb 14 12:57:17 2019
>
> New Revision: 354060
>
>
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D354060-26view-3Drev&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4Vlbja-cwHg4BR5iGcPPSY0HiVU411Nuh0c1lGkXVqc&s=32t3xPHPVY9Rh0eIJaZUSvDcHl5aVmMN1G5ZYHUgd_s&e=
>
> Log:
>
> [CMake] Fix ability to use LLVM_ENABLE_PROJECTS with LLVM_EXTERNAL_PROJECTS
>
>
>
> LLVM r353148, changed the circumstances in which the project source directory variables are created to only create them for LLVM projects. This patch initializes the directory variables for projects specified in `LLVM_EXTERNAL_PROJECTS` as well.
>
>
>
> Modified:
>
>     llvm/trunk/CMakeLists.txt
>
>
>
> Modified: llvm/trunk/CMakeLists.txt
>
> URL: https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_CMakeLists.txt-3Frev-3D354060-26r1-3D354059-26r2-3D354060-26view-3Ddiff&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4Vlbja-cwHg4BR5iGcPPSY0HiVU411Nuh0c1lGkXVqc&s=1vi2z3nIlyyCbenQQhieMECxeIuoL_uOn6ov7gJaMms&e=
>
> ==============================================================================
>
> --- llvm/trunk/CMakeLists.txt (original)
>
> +++ llvm/trunk/CMakeLists.txt Thu Feb 14 12:57:17 2019
>
> @@ -130,7 +130,7 @@ mark_as_advanced(LLVM_ENABLE_PROJECTS_US
>
> if (LLVM_ENABLE_PROJECTS_USED OR NOT LLVM_ENABLE_PROJECTS STREQUAL "")
>
>    set(LLVM_ENABLE_PROJECTS_USED ON CACHE BOOL "" FORCE)
>
> -  foreach(proj ${LLVM_ALL_PROJECTS})
>
> +  foreach(proj ${LLVM_ALL_PROJECTS} ${LLVM_EXTERNAL_PROJECTS})
>
>      string(TOUPPER "${proj}" upper_proj)
>
>      string(REGEX REPLACE "-" "_" upper_proj ${upper_proj})
>
>      if ("${proj}" IN_LIST LLVM_ENABLE_PROJECTS)
>
>
>
>
>
> _______________________________________________
>
> llvm-commits mailing list
>
> llvm-commits at lists.llvm.org
>
> https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_llvm-2Dcommits&d=DwIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=o3kDXzdBUE3ljQXKeTWOMw&m=4Vlbja-cwHg4BR5iGcPPSY0HiVU411Nuh0c1lGkXVqc&s=tzSy2Djkr60mcLcu9eUj39uP2-BlEKldsbiPE_WE1GI&e=
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list