[compiler-rt] r202797 - [CMake] Port add_sanitizer_rt_symbols to CMake 3.0
Alexey Samsonov
samsonov at google.com
Tue Mar 4 00:32:44 PST 2014
Author: samsonov
Date: Tue Mar 4 02:32:43 2014
New Revision: 202797
URL: http://llvm.org/viewvc/llvm-project?rev=202797&view=rev
Log:
[CMake] Port add_sanitizer_rt_symbols to CMake 3.0
Patch by Brad King.
Our add_sanitizer_rt_symbols macro reads the LOCATION property of a
library to compute the location of the "lib<name>.a.syms" file to
generate next to the corresponding "lib<name>.a" library file. CMake
3.0 introduces policy CMP0026 to disallow reading of the LOCATION target
property from non-imported targets in favor of the more powerful
$<TARGET_FILE> generator expression.
Teach add_sanitizer_rt_symbols to use the $<TARGET_FILE> generator
expression to compute the location of the symbols file to generate
with a custom command. CMake 3.0 also adds support for generator
expressions to install(FILES) so use it when available to simplify
installation of the symbols file of the proper configuration.
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=202797&r1=202796&r2=202797&view=diff
==============================================================================
--- compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake (original)
+++ compiler-rt/trunk/cmake/Modules/SanitizerUtils.cmake Tue Mar 4 02:32:43 2014
@@ -12,21 +12,24 @@ set(SANITIZER_LINT_SCRIPT
# symbol names that should be exported as well.
# add_sanitizer_rt_symbols(<name> <files with extra symbols to export>)
macro(add_sanitizer_rt_symbols name)
- get_target_property(libfile ${name} LOCATION)
- set(symsfile "${libfile}.syms")
- add_custom_command(OUTPUT ${symsfile}
+ set(stamp ${CMAKE_CURRENT_BINARY_DIR}/${name}.syms-stamp)
+ add_custom_command(OUTPUT ${stamp}
COMMAND ${PYTHON_EXECUTABLE}
- ${SANITIZER_GEN_DYNAMIC_LIST} ${libfile} ${ARGN}
- > ${symsfile}
+ ${SANITIZER_GEN_DYNAMIC_LIST} $<TARGET_FILE:${name}> ${ARGN}
+ > $<TARGET_FILE:${name}>.syms
+ COMMAND ${CMAKE_COMMAND} -E touch ${stamp}
DEPENDS ${name} ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating exported symbols for ${name}"
VERBATIM)
add_custom_target(${name}-symbols ALL
- DEPENDS ${symsfile}
+ DEPENDS ${stamp}
SOURCES ${SANITIZER_GEN_DYNAMIC_LIST} ${ARGN})
- if(TRUE)
+ if(NOT CMAKE_VERSION VERSION_LESS 3.0)
+ install(FILES $<TARGET_FILE:${name}>.syms
+ DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+ else()
# Per-config install location.
if(CMAKE_CONFIGURATION_TYPES)
foreach(c ${CMAKE_CONFIGURATION_TYPES})
More information about the llvm-commits
mailing list