From cbac3e404c48bd0a7d63f24d01437ea8b881a834 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 4 Mar 2014 08:28:43 +0000 Subject: [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_ 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. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@202796 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/Modules/SanitizerUtils.cmake | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'cmake/Modules/SanitizerUtils.cmake') diff --git a/cmake/Modules/SanitizerUtils.cmake b/cmake/Modules/SanitizerUtils.cmake index aa7be300c..23c6d7b19 100644 --- a/cmake/Modules/SanitizerUtils.cmake +++ b/cmake/Modules/SanitizerUtils.cmake @@ -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. -- cgit v1.2.3