[llvm/cmake] Replace CMAKE_SOURCE_DIR with PROJECT_SOURCE_DIR
authorSebastian Neubauer <Sebastian.Neubauer@amd.com>
Wed, 11 Jan 2023 17:42:00 +0000 (18:42 +0100)
committerSebastian Neubauer <Sebastian.Neubauer@amd.com>
Thu, 12 Jan 2023 10:37:09 +0000 (11:37 +0100)
When adding llvm to a build with add_subdirectory, CMAKE_SOURCE_DIR
refers to the source directory of the parent project. We want to use
PROJECT_SOURCE_DIR instead.

Differential Revision: https://reviews.llvm.org/D141521

llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/include/llvm/TargetParser/CMakeLists.txt
llvm/unittests/Target/PowerPC/CMakeLists.txt
llvm/unittests/Target/WebAssembly/CMakeLists.txt
llvm/unittests/Target/X86/CMakeLists.txt

index 4f4a64b..b6fd175 100644 (file)
@@ -938,7 +938,7 @@ if(LLVM_USE_SANITIZER)
     append("-fsanitize=fuzzer-no-link" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
   endif()
   if (LLVM_USE_SANITIZER MATCHES ".*Undefined.*")
-    set(IGNORELIST_FILE "${CMAKE_SOURCE_DIR}/utils/sanitizers/ubsan_ignorelist.txt")
+    set(IGNORELIST_FILE "${PROJECT_SOURCE_DIR}/utils/sanitizers/ubsan_ignorelist.txt")
     if (EXISTS "${IGNORELIST_FILE}")
       # Use this option name version since -fsanitize-ignorelist is only
       # accepted with clang 13.0 or newer.
index d102dcf..7f080e0 100644 (file)
@@ -1,4 +1,3 @@
-set(LLVM_TARGET_DEFINITIONS ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
-tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I ${CMAKE_SOURCE_DIR}/lib/Target/RISCV/)
+set(LLVM_TARGET_DEFINITIONS ${PROJECT_SOURCE_DIR}/lib/Target/RISCV/RISCV.td)
+tablegen(LLVM RISCVTargetParserDef.inc -gen-riscv-target-def -I ${PROJECT_SOURCE_DIR}/lib/Target/RISCV/)
 add_public_tablegen_target(RISCVTargetParserTableGen)
-
index fb5344d..893e758 100644 (file)
@@ -1,6 +1,6 @@
 include_directories(
-  ${CMAKE_SOURCE_DIR}/lib/Target/PowerPC
-  ${CMAKE_BINARY_DIR}/lib/Target/PowerPC
+  ${PROJECT_SOURCE_DIR}/lib/Target/PowerPC
+  ${PROJECT_BINARY_DIR}/lib/Target/PowerPC
   )
 
 set(LLVM_LINK_COMPONENTS
index 141c2a0..1a8013b 100644 (file)
@@ -1,6 +1,6 @@
 include_directories(
-  ${CMAKE_SOURCE_DIR}/lib/Target/WebAssembly
-  ${CMAKE_BINARY_DIR}/lib/Target/WebAssembly
+  ${PROJECT_SOURCE_DIR}/lib/Target/WebAssembly
+  ${PROJECT_BINARY_DIR}/lib/Target/WebAssembly
   )
 
 set(LLVM_LINK_COMPONENTS
index 3c817ea..ca0b7d1 100644 (file)
@@ -1,6 +1,6 @@
 include_directories(
-  ${CMAKE_SOURCE_DIR}/lib/Target/X86
-  ${CMAKE_BINARY_DIR}/lib/Target/X86
+  ${PROJECT_SOURCE_DIR}/lib/Target/X86
+  ${PROJECT_BINARY_DIR}/lib/Target/X86
   )
 
 set(LLVM_LINK_COMPONENTS