diff options
author | Etienne Bergeron <etienneb@google.com> | 2016-05-16 14:58:07 +0000 |
---|---|---|
committer | Etienne Bergeron <etienneb@google.com> | 2016-05-16 14:58:07 +0000 |
commit | 4659e3654e4d1c0214513d1e7d81a1edc4e3aadb (patch) | |
tree | c1b0834f03428f4b39d5c8ee900e100d128052d4 /lib/sanitizer_common/tests/CMakeLists.txt | |
parent | 570ee9dd7a6f90b0370a86535cbde6738d0ccf67 (diff) | |
download | compiler-rt-4659e3654e4d1c0214513d1e7d81a1edc4e3aadb.tar.gz |
[compiler-rt] Fix multi-configuration output paths
Summary:
When using a multi-configuration build (i.e. MSVC) the output path where
libraries are dropped is incorrect.
Example:
```
C:\src\llvm\examples>d:\src\llvm\build\Release\bin\clang-cl.exe -fsanitize=address test.cc
LINK : fatal error LNK1181: cannot open input file 'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\clang_rt.asan-i386.lib'
```
The dropped executable path contains the configuration 'Release':
```
'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\Release\clang_rt.asan-i386.lib'
```
The variable 'RUNTIME_OUTPUT_DIRECTORY' is used to specify the output directory.
But CMAKE is appending the current configuration (i.e. Debug, Release).
see: https://cmake.org/cmake/help/v3.0/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html
```
"Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory."
```
To avoid this problem, the configuration specific variable must be set:
'RUNTIME_OUTPUT_DIRECTORY_DEBUG', 'RUNTIME_OUTPUT_DIRECTORY_RELEASE', and so on.
Reviewers: ddunbar, chapuni, rnk
Subscribers: kubabrecka, llvm-commits
Differential Revision: http://reviews.llvm.org/D20261
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@269658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/sanitizer_common/tests/CMakeLists.txt')
-rw-r--r-- | lib/sanitizer_common/tests/CMakeLists.txt | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/sanitizer_common/tests/CMakeLists.txt b/lib/sanitizer_common/tests/CMakeLists.txt index 32055c3f7..0e2871f6f 100644 --- a/lib/sanitizer_common/tests/CMakeLists.txt +++ b/lib/sanitizer_common/tests/CMakeLists.txt @@ -106,10 +106,15 @@ function(get_sanitizer_common_lib_for_arch arch lib lib_name) set(tgt_name "RTSanitizerCommon.test.${arch}") endif() set(${lib} "${tgt_name}" PARENT_SCOPE) + if(CMAKE_CONFIGURATION_TYPES) + set(configuration_path "${CMAKE_CFG_INTDIR}/") + else() + set(configuration_path "") + endif() if(NOT MSVC) - set(${lib_name} "lib${tgt_name}.a" PARENT_SCOPE) + set(${lib_name} "${configuration_path}lib${tgt_name}.a" PARENT_SCOPE) else() - set(${lib_name} "${tgt_name}.lib" PARENT_SCOPE) + set(${lib_name} "${configuration_path}${tgt_name}.lib" PARENT_SCOPE) endif() endfunction() @@ -130,7 +135,11 @@ macro(add_sanitizer_tests_for_arch arch) set(SANITIZER_TEST_OBJECTS) foreach(source ${SANITIZER_TEST_SOURCES}) get_filename_component(basename ${source} NAME) - set(output_obj "${basename}.${arch}.o") + if(CMAKE_CONFIGURATION_TYPES) + set(output_obj "${CMAKE_CFG_INTDIR}/${basename}.${arch}.o") + else() + set(output_obj "${basename}.${arch}.o") + endif() clang_compile(${output_obj} ${source} CFLAGS ${SANITIZER_TEST_CFLAGS_COMMON} ${TARGET_FLAGS} DEPS ${SANITIZER_TEST_COMPILE_DEPS}) |