[PATCH] D118792: [lld][clang][cmake] Clean up a few things

2022-02-03 Thread John Ericson via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0eeae9a4470: [lld][clang][cmake] Clean up a few things 
(authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118792/new/

https://reviews.llvm.org/D118792

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt


Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -15,6 +15,10 @@
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
   endif()
 
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -71,24 +71,26 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
-set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
-  endif()
-
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
+set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
+  endif()
+
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
+  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)


Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -15,6 +15,10 @@
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the ll

[PATCH] D118792: [lld][clang][cmake] Clean up a few things

2022-02-03 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

Not very familiar with cmake, but this looks reasonable to me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118792/new/

https://reviews.llvm.org/D118792

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D118792: [lld][clang][cmake] Clean up a few things

2022-02-02 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Ericson2314 added reviewers: nikic, beanz.
Herald added a subscriber: mgorny.
Ericson2314 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- If not using `llvm-config`, `LLVM_MAIN_SRC_DIR` now has a sane default

- `LLVM_CONFIG_PATH` will continue to work for LLD for back compat.

- More quoting of paths in an abundance of caution.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118792

Files:
  clang/CMakeLists.txt
  lld/CMakeLists.txt


Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -15,6 +15,10 @@
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
   endif()
 
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -71,24 +71,26 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
   # LLVM_CONFIG.
   if (NOT LLVM_CONFIG_FOUND)
 # Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
 # path is removed.
-set(MAIN_INCLUDE_DIR ${LLVM_INCLUDE_DIR})
-set(LLVM_OBJ_DIR ${LLVM_BINARY_DIR})
-set(TOOLS_BINARY_DIR ${LLVM_TOOLS_BINARY_DIR})
-set(LIBRARY_DIR ${LLVM_LIBRARY_DIR})
-  endif()
-
-  set(LLVM_MAIN_INCLUDE_DIR ${MAIN_INCLUDE_DIR} CACHE PATH "Path to 
llvm/include")
-  set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
-  set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
-  set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
+set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
+set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
+set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
+  endif()
+
+  set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
+  set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")
+  set(LLVM_MAIN_SRC_DIR "${MAIN_SRC_DIR}" CACHE PATH "Path to LLVM source 
tree")
+  set(LLVM_TOOLS_BINARY_DIR "${TOOLS_BINARY_DIR}" CACHE PATH "Path to 
llvm/bin")
+  set(LLVM_LIBRARY_DIR "${LIBRARY_DIR}" CACHE PATH "Path to llvm/lib")
 
   find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
 NO_DEFAULT_PATH)


Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -15,6 +15,10 @@
 
   # Rely on llvm-config.
   set(LLVM_CONFIG_OUTPUT)
+  if(NOT LLVM_CONFIG)
+   # back compat
+   set(LLVM_CONFIG "${LLVM_CONFIG_PATH}")
+  endif()
   if(LLVM_CONFIG)
 set (LLVM_CONFIG_FOUND 1)
 message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
@@ -55,20 +59,22 @@
   endif()
 
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH ${LLVM_DIR})
+  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
   # We can't check LLVM_CONFIG here, because find_package(LLVM ...) a