[compiler-rt] r202796 - [CMake] Fix add_sanitizer_rt_symbols on multi-config CMake generators.

Alexey Samsonov samsonov at google.com
Tue Mar 4 00:28:43 PST 2014


Author: samsonov
Date: Tue Mar  4 02:28:43 2014
New Revision: 202796

URL: http://llvm.org/viewvc/llvm-project?rev=202796&view=rev
Log:
[CMake] Fix add_sanitizer_rt_symbols on multi-config CMake generators.

Patch by Brad King.

When using a multi-config generator with CMake, such as for VS or Xcode,
the LOCATION target property value contains a placeholder such as
"$(Configuration)" that is meant for substitution by the native build
tool. The install(FILES) command does not understand this name and will
not install the symbols file correctly when using these generators.

Teach add_sanitizer_rt_symbols to read the more-specific target property
LOCATION_<CONFIG> that has a per-configuration value and no placeholder.
On single-configuration generators (Makefile, Ninja), CMAKE_BUILD_TYPE
contains the name of the one configuration to be built.  On multi-config
generators (VS, Xcode), CMAKE_CONFIGURATION_TYPES contains the list of
possible configurations.  In the latter case, loop over the configs and
add a configuration-specific install(FILES) rule for each one.

Place the code block inside an if(TRUE) block so it can be made
conditional in a following change without updating indentation.

Modified:
    compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake

Modified: compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake?rev=202796&r1=202795&r2=202796&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake Tue Mar  4 02:28:43 2014
@@ -25,7 +25,20 @@ macro(add_sanitizer_rt_symbols name)
   add_custom_target(${name}-symbols ALL
     DEPENDS ${symsfile}
     SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN})
-  install(FILES ${symsfile} DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+
+  if(TRUE)
+    # Per-config install location.
+    if(CMAKE_CONFIGURATION_TYPES)
+      foreach(c ${CMAKE_CONFIGURATION_TYPES})
+        get_target_property(libfile ${name} LOCATION_${c})
+        install(FILES ${libfile}.syms CONFIGURATIONS ${c}
+          DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+      endforeach()
+    else()
+      get_target_property(libfile ${name} LOCATION_${CMAKE_BUILD_TYPE})
+      install(FILES ${libfile}.syms DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+    endif()
+  endif()
 endmacro()
 
 # Add target to check code style for sanitizer runtimes.





More information about the llvm-commits mailing list