Skip to content

Commit

Permalink
[compiler-rt] Fix VisualStudio virtual folders layout
Browse files Browse the repository at this point in the history
Summary:
This patch is a refactoring of the way cmake 'targets' are grouped.
It won't affect non-UI cmake-generators.

Clang/LLVM are using a structured way to group targets which ease
navigation through Visual Studio UI. The Compiler-RT projects
differ from the way Clang/LLVM are grouping targets.

This patch doesn't contain behavior changes.

Reviewers: kubabrecka, rnk

Subscribers: wang0109, llvm-commits, kubabrecka, chrisha

Differential Revision: http://reviews.llvm.org/D21952

llvm-svn: 275111
  • Loading branch information
bergeret committed Jul 11, 2016
1 parent dbeaea7 commit ab42f4d
Show file tree
Hide file tree
Showing 29 changed files with 76 additions and 47 deletions.
58 changes: 34 additions & 24 deletions compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -1,6 +1,28 @@
include(ExternalProject)
include(CompilerRTUtils)

function(set_target_output_directories target output_dir)
# For RUNTIME_OUTPUT_DIRECTORY variable, Multi-configuration generators
# append a per-configuration subdirectory to the specified directory.
# To avoid the appended folder, the configuration specific variable must be
# set 'RUNTIME_OUTPUT_DIRECTORY_${CONF}':
# RUNTIME_OUTPUT_DIRECTORY_DEBUG, RUNTIME_OUTPUT_DIRECTORY_RELEASE, ...
if(CMAKE_CONFIGURATION_TYPES)
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
set_target_properties("${target}" PROPERTIES
"ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${output_dir}
"LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${output_dir}
"RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${output_dir})
endforeach()
else()
set_target_properties("${target}" PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${output_dir}
LIBRARY_OUTPUT_DIRECTORY ${output_dir}
RUNTIME_OUTPUT_DIRECTORY ${output_dir})
endif()
endfunction()

# Tries to add an "object library" target for a given list of OSs and/or
# architectures with name "<name>.<arch>" for non-Darwin platforms if
# architecture can be targeted, and "<name>.<os>" for Darwin platforms.
Expand Down Expand Up @@ -31,13 +53,14 @@ function(add_compiler_rt_object_libraries name)
endif()
endforeach()
endif()

foreach(libname ${libnames})
add_library(${libname} OBJECT ${LIB_SOURCES})
set_target_compile_flags(${libname}
${CMAKE_CXX_FLAGS} ${extra_cflags_${libname}} ${LIB_CFLAGS})
set_property(TARGET ${libname} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})
set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Libraries")
if(APPLE)
set_target_properties(${libname} PROPERTIES
OSX_ARCHITECTURES "${LIB_ARCHS_${libname}}")
Expand Down Expand Up @@ -139,11 +162,13 @@ function(add_compiler_rt_runtime name type)
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=${LIB_PARENT_TARGET}
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
set_target_properties(install-${LIB_PARENT_TARGET} PROPERTIES
FOLDER "Compiler-RT Misc")
endif()
endif()

foreach(libname ${libnames})
# If you have are using a multi-configuration generator we don't generate
# If you are using a multi-configuration generator we don't generate
# per-library install rules, so we fall back to the parent target COMPONENT
if(CMAKE_CONFIGURATION_TYPES AND LIB_PARENT_TARGET)
set(COMPONENT_OPTION COMPONENT ${LIB_PARENT_TARGET})
Expand All @@ -154,31 +179,12 @@ function(add_compiler_rt_runtime name type)
add_library(${libname} ${type} ${sources_${libname}})
set_target_compile_flags(${libname} ${extra_cflags_${libname}})
set_target_link_flags(${libname} ${extra_linkflags_${libname}})
set_property(TARGET ${libname} APPEND PROPERTY
set_property(TARGET ${libname} APPEND PROPERTY
COMPILE_DEFINITIONS ${LIB_DEFS})

# For RUNTIME_OUTPUT_DIRECTORY variable, Multi-configuration generators
# append a per-configuration subdirectory to the specified directory.
# To avoid the appended folder, the configuration specific variable must be
# set 'RUNTIME_OUTPUT_DIRECTORY_${CONF}':
# RUNTIME_OUTPUT_DIRECTORY_DEBUG, RUNTIME_OUTPUT_DIRECTORY_RELEASE, ...
if(CMAKE_CONFIGURATION_TYPES)
foreach(build_mode ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER "${build_mode}" CONFIG_SUFFIX)
set_target_properties(${libname} PROPERTIES
"ARCHIVE_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
"LIBRARY_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
"RUNTIME_OUTPUT_DIRECTORY_${CONFIG_SUFFIX}" ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
endforeach()
else()
set_target_properties(${libname} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
endif()

set_target_output_directories(${libname} ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
set_target_properties(${libname} PROPERTIES
OUTPUT_NAME ${output_name_${libname}})
set_target_properties(${libname} PROPERTIES FOLDER "Compiler-RT Runtime")
if(LIB_LINK_LIBS AND ${type} STREQUAL "SHARED")
target_link_libraries(${libname} ${LIB_LINK_LIBS})
endif()
Expand Down Expand Up @@ -296,6 +302,8 @@ macro(add_compiler_rt_test test_suite test_name)
-o "${output_bin}"
${TEST_LINK_FLAGS}
DEPENDS ${TEST_DEPS})
set_target_properties(${test_name} PROPERTIES FOLDER "Compiler-RT Tests")

# Make the test suite depend on the binary.
add_dependencies(${test_suite} ${test_name})
endmacro()
Expand All @@ -313,6 +321,8 @@ macro(add_compiler_rt_resource_file target_name file_name component)
DESTINATION ${COMPILER_RT_INSTALL_PATH}
COMPONENT ${component})
add_dependencies(${component} ${target_name})

set_target_properties(${target_name} PROPERTIES FOLDER "Compiler-RT Misc")
endmacro()

macro(add_compiler_rt_script name)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/cmake/base-config-ix.cmake
Expand Up @@ -8,6 +8,7 @@ check_include_file(unwind.h HAVE_UNWIND_H)

# Top level target used to build all compiler-rt libraries.
add_custom_target(compiler-rt ALL)
set_target_properties(compiler-rt PROPERTIES FOLDER "Compiler-RT Misc")

# Setting these variables from an LLVM build is sufficient that compiler-rt can
# construct the output paths, so it can behave as if it were in-tree here.
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/include/CMakeLists.txt
Expand Up @@ -26,6 +26,7 @@ endforeach( f )

add_custom_target(compiler-rt-headers ALL DEPENDS ${out_files})
add_dependencies(compiler-rt compiler-rt-headers)
set_target_properties(compiler-rt-headers PROPERTIES FOLDER "Compiler-RT Misc")

# Install sanitizer headers.
install(FILES ${SANITIZER_HEADERS}
Expand Down
15 changes: 8 additions & 7 deletions compiler-rt/lib/asan/tests/CMakeLists.txt
Expand Up @@ -155,12 +155,12 @@ macro(add_asan_test test_suite test_name arch kind)
else()
set(configuration_path "")
endif()
if(NOT MSVC)
if(NOT MSVC)
set(asan_test_runtime_path ${configuration_path}lib${ASAN_TEST_RUNTIME}.a)
else()
set(asan_test_runtime_path ${configuration_path}${ASAN_TEST_RUNTIME}.lib)
endif()
list(APPEND TEST_OBJECTS ${asan_test_runtime_path})
list(APPEND TEST_OBJECTS ${asan_test_runtime_path})
endif()
add_compiler_rt_test(${test_suite} ${test_name}
SUBDIR ${TEST_SUBDIR}
Expand All @@ -172,15 +172,15 @@ endmacro()

# Main AddressSanitizer unit tests.
add_custom_target(AsanUnitTests)
set_target_properties(AsanUnitTests PROPERTIES FOLDER "ASan unit tests")
set_target_properties(AsanUnitTests PROPERTIES FOLDER "Compiler-RT Tests")

# AddressSanitizer unit tests with dynamic runtime (on platforms where it's
# not the default).
add_custom_target(AsanDynamicUnitTests)
set_target_properties(AsanDynamicUnitTests
PROPERTIES FOLDER "ASan unit tests with dynamic runtime")
set_target_properties(AsanDynamicUnitTests PROPERTIES FOLDER "Compiler-RT Tests")
# ASan benchmarks (not actively used now).
add_custom_target(AsanBenchmarks)
set_target_properties(AsanBenchmarks PROPERTIES FOLDER "Asan benchmarks")
set_target_properties(AsanBenchmarks PROPERTIES FOLDER "Compiler-RT Tests")

set(ASAN_NOINST_TEST_SOURCES
${COMPILER_RT_GTEST_SOURCE}
Expand Down Expand Up @@ -272,7 +272,8 @@ macro(add_asan_tests_for_arch_and_kind arch kind)
endif()
add_library(${ASAN_TEST_RUNTIME} STATIC ${ASAN_TEST_RUNTIME_OBJECTS})
set_target_properties(${ASAN_TEST_RUNTIME} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
FOLDER "Compiler-RT Runtime tests")
# Uninstrumented tests.
set(ASAN_NOINST_TEST_OBJECTS)
foreach(src ${ASAN_NOINST_TEST_SOURCES})
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/builtins/CMakeLists.txt
Expand Up @@ -386,6 +386,7 @@ set(wasm32_SOURCES ${GENERIC_SOURCES})
set(wasm64_SOURCES ${GENERIC_SOURCES})

add_custom_target(builtins)
set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")

if (APPLE)
add_subdirectory(Darwin-excludes)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/cfi/CMakeLists.txt
@@ -1,4 +1,5 @@
add_custom_target(cfi)
set_target_properties(cfi PROPERTIES FOLDER "Compiler-RT Misc")

set(CFI_SOURCES cfi.cc)

Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/dfsan/CMakeLists.txt
Expand Up @@ -12,6 +12,8 @@ append_list_if(COMPILER_RT_HAS_FFREESTANDING_FLAG -ffreestanding DFSAN_COMMON_CF

# Static runtime library.
add_custom_target(dfsan)
set_target_properties(dfsan PROPERTIES FOLDER "Compiler-RT Misc")

foreach(arch ${DFSAN_SUPPORTED_ARCH})
set(DFSAN_CFLAGS ${DFSAN_COMMON_CFLAGS})
append_list_if(COMPILER_RT_HAS_FPIE_FLAG -fPIE DFSAN_CFLAGS)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/esan/CMakeLists.txt
@@ -1,6 +1,7 @@
# Build for the EfficiencySanitizer runtime support library.

add_custom_target(esan)
set_target_properties(esan PROPERTIES FOLDER "Compiler-RT Misc")

set(ESAN_RTL_CFLAGS ${SANITIZER_COMMON_CFLAGS})
append_rtti_flag(OFF ESAN_RTL_CFLAGS)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/lsan/CMakeLists.txt
Expand Up @@ -17,6 +17,7 @@ set(LSAN_SOURCES
set(LSAN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})

add_custom_target(lsan)
set_target_properties(lsan PROPERTIES FOLDER "Compiler-RT Misc")

add_compiler_rt_object_libraries(RTLSanCommon
OS ${SANITIZER_COMMON_SUPPORTED_OS}
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/msan/CMakeLists.txt
Expand Up @@ -26,6 +26,8 @@ set(MSAN_RUNTIME_LIBRARIES)

# Static runtime library.
add_custom_target(msan)
set_target_properties(msan PROPERTIES FOLDER "Compiler-RT Misc")

foreach(arch ${MSAN_SUPPORTED_ARCH})
add_compiler_rt_runtime(clang_rt.msan
STATIC
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/profile/CMakeLists.txt
Expand Up @@ -39,6 +39,7 @@ int main() {
" COMPILER_RT_TARGET_HAS_FCNTL_LCK)

add_custom_target(profile)
set_target_properties(profile PROPERTIES FOLDER "Compiler-RT Misc")

set(PROFILE_SOURCES
GCDAProfiling.c
Expand Down
2 changes: 2 additions & 0 deletions compiler-rt/lib/safestack/CMakeLists.txt
@@ -1,4 +1,6 @@
add_custom_target(safestack)
set_target_properties(safestack PROPERTIES
FOLDER "Compiler-RT Misc")

set(SAFESTACK_SOURCES safestack.cc)

Expand Down
6 changes: 3 additions & 3 deletions compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt
Expand Up @@ -107,7 +107,8 @@ include_directories(../..)
macro(add_sanitizer_common_lib library)
add_library(${library} STATIC ${ARGN})
set_target_properties(${library} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
FOLDER "Compiler-RT Runtime tests")
endmacro()

function(get_sanitizer_common_lib_for_arch arch lib lib_name)
Expand All @@ -131,8 +132,7 @@ endfunction()

# Sanitizer_common unit tests testsuite.
add_custom_target(SanitizerUnitTests)
set_target_properties(SanitizerUnitTests PROPERTIES
FOLDER "Sanitizer unittests")
set_target_properties(SanitizerUnitTests PROPERTIES FOLDER "Compiler-RT Tests")

# Adds sanitizer tests for architecture.
macro(add_sanitizer_tests_for_arch arch)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/scudo/CMakeLists.txt
@@ -1,4 +1,5 @@
add_custom_target(scudo)
set_target_properties(scudo PROPERTIES FOLDER "Compiler-RT Misc")

include_directories(..)

Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/stats/CMakeLists.txt
@@ -1,6 +1,7 @@
include_directories(..)

add_custom_target(stats)
set_target_properties(stats PROPERTIES FOLDER "Compiler-RT Misc")

if(APPLE)
set(STATS_LIB_FLAVOR SHARED)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/tsan/CMakeLists.txt
Expand Up @@ -97,6 +97,7 @@ set(TSAN_HEADERS

set(TSAN_RUNTIME_LIBRARIES)
add_custom_target(tsan)
set_target_properties(tsan PROPERTIES FOLDER "Compiler-RT Misc")

if(APPLE)
set(TSAN_ASM_SOURCES rtl/tsan_rtl_amd64.S)
Expand Down
1 change: 1 addition & 0 deletions compiler-rt/lib/ubsan/CMakeLists.txt
Expand Up @@ -34,6 +34,7 @@ append_rtti_flag(ON UBSAN_STANDALONE_CXXFLAGS)
append_list_if(SANITIZER_CAN_USE_CXXABI -DUBSAN_CAN_USE_CXXABI UBSAN_CXXFLAGS)

add_custom_target(ubsan)
set_target_properties(ubsan PROPERTIES FOLDER "Compiler-RT Misc")

if(APPLE)
set(UBSAN_COMMON_SOURCES ${UBSAN_SOURCES})
Expand Down
4 changes: 2 additions & 2 deletions compiler-rt/test/asan/CMakeLists.txt
Expand Up @@ -103,7 +103,7 @@ endif()
add_lit_testsuite(check-asan "Running the AddressSanitizer tests"
${ASAN_TESTSUITES}
DEPENDS ${ASAN_TEST_DEPS})
set_target_properties(check-asan PROPERTIES FOLDER "ASan tests")
set_target_properties(check-asan PROPERTIES FOLDER "Compiler-RT Misc")

if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
# Add check-dynamic-asan target. It is a part of check-all only on Windows,
Expand All @@ -117,7 +117,7 @@ if(COMPILER_RT_ASAN_HAS_STATIC_RUNTIME)
${ASAN_DYNAMIC_TESTSUITES}
DEPENDS ${ASAN_DYNAMIC_TEST_DEPS})
set_target_properties(check-asan-dynamic
PROPERTIES FOLDER "ASan dynamic tests")
PROPERTIES FOLDER "Compiler-RT Misc")
if(NOT OS_NAME MATCHES "Windows")
set(EXCLUDE_FROM_ALL FALSE)
endif()
Expand Down
3 changes: 2 additions & 1 deletion compiler-rt/test/cfi/CMakeLists.txt
Expand Up @@ -49,4 +49,5 @@ add_lit_target(check-cfi-and-supported "Running the cfi regression tests"
PARAMS check_supported=1
DEPENDS ${CFI_TEST_DEPS})

set_target_properties(check-cfi PROPERTIES FOLDER "Tests")
set_target_properties(check-cfi PROPERTIES FOLDER "Compiler-RT Misc")
set_target_properties(check-cfi-and-supported PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/dfsan/CMakeLists.txt
Expand Up @@ -37,4 +37,4 @@ endif()
add_lit_testsuite(check-dfsan "Running the DataFlowSanitizer tests"
${DFSAN_TESTSUITES}
DEPENDS ${DFSAN_TEST_DEPS})
set_target_properties(check-dfsan PROPERTIES FOLDER "DFSan tests")
set_target_properties(check-dfsan PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/esan/CMakeLists.txt
Expand Up @@ -29,4 +29,4 @@ endforeach()
add_lit_testsuite(check-esan "Running EfficiencySanitizer tests"
${ESAN_TESTSUITES}
DEPENDS ${ESAN_TEST_DEPS})
set_target_properties(check-esan PROPERTIES FOLDER "Esan tests")
set_target_properties(check-esan PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/lsan/CMakeLists.txt
Expand Up @@ -45,4 +45,4 @@ endif()
add_lit_testsuite(check-lsan "Running the LeakSanitizer tests"
${LSAN_TESTSUITES}
DEPENDS ${LSAN_TEST_DEPS})
set_target_properties(check-lsan PROPERTIES FOLDER "LSan tests")
set_target_properties(check-lsan PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/msan/CMakeLists.txt
Expand Up @@ -46,4 +46,4 @@ add_lit_testsuite(check-msan "Running the MemorySanitizer tests"
${MSAN_TESTSUITES}
DEPENDS ${MSAN_TEST_DEPS}
)
set_target_properties(check-msan PROPERTIES FOLDER "MSan tests")
set_target_properties(check-msan PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/profile/CMakeLists.txt
Expand Up @@ -32,4 +32,4 @@ endforeach()
add_lit_testsuite(check-profile "Running the profile tests"
${PROFILE_TESTSUITES}
DEPENDS ${PROFILE_TEST_DEPS})
set_target_properties(check-profile PROPERTIES FOLDER "Profile tests")
set_target_properties(check-profile PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/safestack/CMakeLists.txt
Expand Up @@ -26,4 +26,4 @@ configure_lit_site_cfg(
add_lit_testsuite(check-safestack "Running the SafeStack tests"
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${SAFESTACK_TEST_DEPS})
set_target_properties(check-safestack PROPERTIES FOLDER "SafeStack tests")
set_target_properties(check-safestack PROPERTIES FOLDER "Compiler-RT Misc")
2 changes: 1 addition & 1 deletion compiler-rt/test/sanitizer_common/CMakeLists.txt
Expand Up @@ -60,5 +60,5 @@ if(SANITIZER_COMMON_TESTSUITES AND
${SANITIZER_COMMON_TESTSUITES}
DEPENDS ${SANITIZER_COMMON_TEST_DEPS})
set_target_properties(check-sanitizer PROPERTIES FOLDER
"sanitizer_common tests")
"Compiler-RT Misc")
endif()
2 changes: 1 addition & 1 deletion compiler-rt/test/scudo/CMakeLists.txt
Expand Up @@ -24,5 +24,5 @@ if (SSE42_TRUE AND CMAKE_SIZEOF_VOID_P EQUAL 8)
${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${SCUDO_TEST_DEPS})
set_target_properties(check-scudo PROPERTIES FOLDER
"Scudo Hardened Allocator tests")
"Compiler-RT Misc")
endif(SSE42_TRUE AND CMAKE_SIZEOF_VOID_P EQUAL 8)
2 changes: 1 addition & 1 deletion compiler-rt/test/tsan/CMakeLists.txt
Expand Up @@ -54,4 +54,4 @@ endif()
add_lit_testsuite(check-tsan "Running ThreadSanitizer tests"
${TSAN_TESTSUITES}
DEPENDS ${TSAN_TEST_DEPS})
set_target_properties(check-tsan PROPERTIES FOLDER "TSan tests")
set_target_properties(check-tsan PROPERTIES FOLDER "Compiler-RT Tests")
2 changes: 1 addition & 1 deletion compiler-rt/test/ubsan/CMakeLists.txt
Expand Up @@ -49,4 +49,4 @@ endforeach()
add_lit_testsuite(check-ubsan "Running UndefinedBehaviorSanitizer tests"
${UBSAN_TESTSUITES}
DEPENDS ${UBSAN_TEST_DEPS})
set_target_properties(check-ubsan PROPERTIES FOLDER "UBSan tests")
set_target_properties(check-ubsan PROPERTIES FOLDER "Compiler-RT Misc")

0 comments on commit ab42f4d

Please sign in to comment.