[llvm] r280162 - [CMake] Ensure that compiler-rt is added first

Chris Bieneman via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 30 14:29:21 PDT 2016


Author: cbieneman
Date: Tue Aug 30 16:29:21 2016
New Revision: 280162

URL: http://llvm.org/viewvc/llvm-project?rev=280162&view=rev
Log:
[CMake] Ensure that compiler-rt is added first

This will enable other runtime projects to detect the presence of sanitizer runtimes by referring to the sanitizer targets directly.

Modified:
    llvm/trunk/runtimes/CMakeLists.txt

Modified: llvm/trunk/runtimes/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/runtimes/CMakeLists.txt?rev=280162&r1=280161&r2=280162&view=diff
==============================================================================
--- llvm/trunk/runtimes/CMakeLists.txt (original)
+++ llvm/trunk/runtimes/CMakeLists.txt Tue Aug 30 16:29:21 2016
@@ -33,6 +33,21 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_
     "${LLVM_BINARY_DIR}/lib/cmake/llvm"
   )
 
+  # Some of the runtimes will conditionally use the compiler-rt sanitizers
+  # to make this work smoothly we ensure that compiler-rt is added first in
+  # the list of sub-projects. This allows other sub-projects to have checks
+  # like `if(TARGET asan)` to enable building with asan.
+  foreach(entry ${runtimes})
+    if("${entry}" MATCHES "compiler-rt")
+      set(compiler_rt_path ${entry})
+      break()
+    endif()
+  endforeach()
+  if(compiler_rt_path)
+    list(REMOVE_ITEM runtimes ${compiler_rt_path})
+    list(INSERT runtimes 0 ${compiler_rt_path})
+  endif()
+
   # LLVMConfig.cmake contains a bunch of CMake variables from the LLVM build.
   # This file is installed as part of LLVM distributions, so this can be used
   # either from a build directory or an installed LLVM.




More information about the llvm-commits mailing list