@@ -4,6 +4,21 @@ include(LLVMProcessSources)
4
4
include (LLVM-Config )
5
5
include (DetermineGCCCompatible )
6
6
7
+ # get_subproject_title(titlevar)
8
+ # Set ${outvar} to the title of the current LLVM subproject (Clang, MLIR ...)
9
+ #
10
+ # The title is set in the subproject's top-level using the variable
11
+ # LLVM_SUBPROJECT_TITLE. If it does not exist, it is assumed it is LLVM itself.
12
+ # The title is not semantically significant, but use to create folders in
13
+ # CMake-generated IDE projects (Visual Studio/XCode).
14
+ function (get_subproject_title outvar )
15
+ if (LLVM_SUBPROJECT_TITLE )
16
+ set (${outvar} "${LLVM_SUBPROJECT_TITLE} " PARENT_SCOPE )
17
+ else ()
18
+ set (${outvar} "LLVM" PARENT_SCOPE )
19
+ endif ()
20
+ endfunction (get_subproject_title )
21
+
7
22
function (llvm_update_compile_flags name )
8
23
get_property (sources TARGET ${name} PROPERTY SOURCES )
9
24
if ("${sources} " MATCHES "\\ .c(;|$)" )
@@ -151,7 +166,8 @@ function(add_llvm_symbol_exports target_name export_file)
151
166
endif ()
152
167
153
168
add_custom_target (${target_name} _exports DEPENDS ${native_export_file} )
154
- set_target_properties (${target_name} _exports PROPERTIES FOLDER "Misc" )
169
+ get_subproject_title (subproject_title )
170
+ set_target_properties (${target_name} _exports PROPERTIES FOLDER "${subproject_title} /API" )
155
171
156
172
get_property (srcs TARGET ${target_name} PROPERTY SOURCES )
157
173
foreach (src ${srcs} )
@@ -543,6 +559,8 @@ function(llvm_add_library name)
543
559
endif ()
544
560
endif ()
545
561
562
+ get_subproject_title (subproject_title )
563
+
546
564
# Generate objlib
547
565
if ((ARG_SHARED AND ARG_STATIC ) OR ARG_OBJECT )
548
566
# Generate an obj library for both targets.
@@ -564,7 +582,7 @@ function(llvm_add_library name)
564
582
# Bring in the target include directories from our original target.
565
583
target_include_directories (${obj_name} PRIVATE $< TARGET_PROPERTY:${name} ,INCLUDE_DIRECTORIES> )
566
584
567
- set_target_properties (${obj_name} PROPERTIES FOLDER "Object Libraries" )
585
+ set_target_properties (${obj_name} PROPERTIES FOLDER "${subproject_title} / Object Libraries" )
568
586
if (ARG_DEPENDS )
569
587
add_dependencies (${obj_name} ${ARG_DEPENDS} )
570
588
endif ()
@@ -603,6 +621,7 @@ function(llvm_add_library name)
603
621
LINK_LIBS ${ARG_LINK_LIBS}
604
622
LINK_COMPONENTS ${ARG_LINK_COMPONENTS}
605
623
)
624
+ set_target_properties (${name_static} PROPERTIES FOLDER "${subproject_title} /Libraries" )
606
625
607
626
# Bring in the target link info from our original target.
608
627
target_link_directories (${name_static} PRIVATE $< TARGET_PROPERTY:${name} ,LINK_DIRECTORIES> )
@@ -620,6 +639,7 @@ function(llvm_add_library name)
620
639
else ()
621
640
add_library (${name} STATIC ${ALL_FILES} )
622
641
endif ()
642
+ set_target_properties (${name} PROPERTIES FOLDER "${subproject_title} /Libraries" )
623
643
624
644
if (ARG_COMPONENT_LIB )
625
645
set_target_properties (${name} PROPERTIES LLVM_COMPONENT TRUE )
@@ -796,14 +816,16 @@ function(add_llvm_install_targets target)
796
816
endif ()
797
817
endforeach ()
798
818
819
+ get_subproject_title (subproject_title )
820
+
799
821
add_custom_target (${target}
800
822
DEPENDS ${file_dependencies}
801
823
COMMAND "${CMAKE_COMMAND} "
802
824
${component_option}
803
825
${prefix_option}
804
826
-P "${CMAKE_BINARY_DIR} /cmake_install.cmake"
805
827
USES_TERMINAL )
806
- set_target_properties (${target} PROPERTIES FOLDER "Component Install Targets " )
828
+ set_target_properties (${target} PROPERTIES FOLDER "${subproject_title} /Installation " )
807
829
add_custom_target (${target} -stripped
808
830
DEPENDS ${file_dependencies}
809
831
COMMAND "${CMAKE_COMMAND} "
@@ -812,7 +834,7 @@ function(add_llvm_install_targets target)
812
834
-DCMAKE_INSTALL_DO_STRIP=1
813
835
-P "${CMAKE_BINARY_DIR} /cmake_install.cmake"
814
836
USES_TERMINAL )
815
- set_target_properties (${target} -stripped PROPERTIES FOLDER "Component Install Targets (Stripped) " )
837
+ set_target_properties (${target} -stripped PROPERTIES FOLDER "${subproject_title} /Installation " )
816
838
if (target_dependencies )
817
839
add_dependencies (${target} ${target_dependencies} )
818
840
add_dependencies (${target} -stripped ${target_dependencies} )
@@ -832,6 +854,8 @@ endfunction()
832
854
function (add_llvm_component_group name )
833
855
cmake_parse_arguments (ARG "HAS_JIT" "" "LINK_COMPONENTS" ${ARGN} )
834
856
add_custom_target (${name} )
857
+ get_subproject_title (subproject_title )
858
+ set_target_properties (${name} PROPERTIES FOLDER "${subproject_title} /Component Groups" )
835
859
if (ARG_HAS_JIT )
836
860
set_property (TARGET ${name} PROPERTY COMPONENT_HAS_JIT ON )
837
861
endif ()
@@ -865,6 +889,8 @@ function(add_llvm_component_library name)
865
889
866
890
if (ARG_ADD_TO_COMPONENT )
867
891
set_property (TARGET ${ARG_ADD_TO_COMPONENT} APPEND PROPERTY LLVM_LINK_COMPONENTS ${component_name} )
892
+ get_subproject_title (subproject_title )
893
+ set_target_properties (${name} PROPERTIES FOLDER "${subproject_title} /Libraries/${ARG_ADD_TO_COMPONENT} " )
868
894
endif ()
869
895
870
896
endfunction ()
@@ -921,10 +947,12 @@ macro(add_llvm_library name)
921
947
endif ()
922
948
set_property (GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name} )
923
949
endif ()
950
+
951
+ get_subproject_title (subproject_title )
924
952
if (ARG_MODULE )
925
- set_target_properties (${name} PROPERTIES FOLDER "Loadable modules " )
953
+ set_target_properties (${name} PROPERTIES FOLDER "${subproject_title} / Loadable Modules " )
926
954
else ()
927
- set_target_properties (${name} PROPERTIES FOLDER "Libraries" )
955
+ set_target_properties (${name} PROPERTIES FOLDER "${subproject_title} / Libraries" )
928
956
endif ()
929
957
endmacro (add_llvm_library name )
930
958
@@ -948,7 +976,8 @@ macro(generate_llvm_objects name)
948
976
add_dependencies (${obj_name} ${ARG_DEPENDS} )
949
977
endif ()
950
978
951
- set_target_properties (${obj_name} PROPERTIES FOLDER "Object Libraries" )
979
+ get_subproject_title (subproject_title )
980
+ set_target_properties (${obj_name} PROPERTIES FOLDER "${subproject_title} /Object Libraries" )
952
981
endif ()
953
982
954
983
if (ARG_GENERATE_DRIVER )
@@ -999,6 +1028,8 @@ macro(add_llvm_executable name)
999
1028
else ()
1000
1029
add_executable (${name} ${ALL_FILES} )
1001
1030
endif ()
1031
+ get_subproject_title (subproject_title )
1032
+ set_target_properties (${name} PROPERTIES FOLDER "${subproject_title} /Executables" )
1002
1033
1003
1034
setup_dependency_debugging (${name} ${LLVM_COMMON_DEPENDS} )
1004
1035
@@ -1418,8 +1449,9 @@ macro(llvm_add_tool project name)
1418
1449
if( LLVM_BUILD_TOOLS )
1419
1450
set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name} )
1420
1451
endif()
1421
- set_target_properties(${name} PROPERTIES FOLDER " Tools ")
1422
1452
endif()
1453
+ get_subproject_title(subproject_title)
1454
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} /Tools ")
1423
1455
endmacro(llvm_add_tool project name)
1424
1456
1425
1457
macro(add_llvm_tool name)
@@ -1435,7 +1467,8 @@ macro(add_llvm_example name)
1435
1467
if( LLVM_BUILD_EXAMPLES )
1436
1468
install(TARGETS ${name} RUNTIME DESTINATION " ${LLVM_EXAMPLES_INSTALL_DIR} ")
1437
1469
endif()
1438
- set_target_properties(${name} PROPERTIES FOLDER " Examples ")
1470
+ get_subproject_title(subproject_title)
1471
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} /Examples ")
1439
1472
endmacro(add_llvm_example name)
1440
1473
1441
1474
macro(add_llvm_example_library name)
@@ -1446,7 +1479,8 @@ macro(add_llvm_example_library name)
1446
1479
add_llvm_library(${name} ${ARGN} )
1447
1480
endif()
1448
1481
1449
- set_target_properties(${name} PROPERTIES FOLDER " Examples ")
1482
+ get_subproject_title(subproject_title)
1483
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} /Examples ")
1450
1484
endmacro(add_llvm_example_library name)
1451
1485
1452
1486
# This is a macro that is used to create targets for executables that are needed
@@ -1457,7 +1491,8 @@ macro(add_llvm_utility name)
1457
1491
endif()
1458
1492
1459
1493
add_llvm_executable(${name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN} )
1460
- set_target_properties(${name} PROPERTIES FOLDER " Utils ")
1494
+ get_subproject_title(subproject_title)
1495
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} /Utils ")
1461
1496
if ( ${name} IN_LIST LLVM_TOOLCHAIN_UTILITIES OR NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
1462
1497
if (LLVM_INSTALL_UTILS AND LLVM_BUILD_UTILS)
1463
1498
get_target_export_arg(${name} LLVM export_to_llvmexports)
@@ -1480,19 +1515,20 @@ endmacro(add_llvm_utility name)
1480
1515
1481
1516
macro(add_llvm_fuzzer name)
1482
1517
cmake_parse_arguments(ARG "" " DUMMY_MAIN " "" ${ARGN} )
1518
+ get_subproject_title(subproject_title)
1483
1519
if( LLVM_LIB_FUZZING_ENGINE )
1484
1520
set(LLVM_OPTIONAL_SOURCES ${ARG_DUMMY_MAIN} )
1485
1521
add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} )
1486
1522
target_link_libraries(${name} PRIVATE ${LLVM_LIB_FUZZING_ENGINE} )
1487
- set_target_properties(${name} PROPERTIES FOLDER " Fuzzers ")
1523
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} / Fuzzers")
1488
1524
elseif( LLVM_USE_SANITIZE_COVERAGE )
1489
1525
set(CMAKE_CXX_FLAGS " ${CMAKE_CXX_FLAGS} -fsanitize=fuzzer ")
1490
1526
set(LLVM_OPTIONAL_SOURCES ${ARG_DUMMY_MAIN} )
1491
1527
add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS} )
1492
- set_target_properties(${name} PROPERTIES FOLDER " Fuzzers ")
1528
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} / Fuzzers")
1493
1529
elseif( ARG_DUMMY_MAIN )
1494
1530
add_llvm_executable(${name} ${ARG_DUMMY_MAIN} ${ARG_UNPARSED_ARGUMENTS} )
1495
- set_target_properties(${name} PROPERTIES FOLDER " Fuzzers ")
1531
+ set_target_properties(${name} PROPERTIES FOLDER " ${subproject_title} / Fuzzers")
1496
1532
endif()
1497
1533
endmacro()
1498
1534
@@ -1653,6 +1689,8 @@ function(add_unittest test_suite test_name)
1653
1689
1654
1690
list(APPEND LLVM_LINK_COMPONENTS Support) # gtest needs it for raw_ostream
1655
1691
add_llvm_executable(${test_name} IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH ${ARGN} )
1692
+ get_subproject_title(subproject_title)
1693
+ set_target_properties(${test_name} PROPERTIES FOLDER " ${subproject_title} /Tests/Unit ")
1656
1694
1657
1695
# The runtime benefits of LTO don't outweight the compile time costs for tests.
1658
1696
if(LLVM_ENABLE_LTO)
@@ -1684,10 +1722,6 @@ function(add_unittest test_suite test_name)
1684
1722
target_link_libraries(${test_name} PRIVATE llvm_gtest_main llvm_gtest ${LLVM_PTHREAD_LIB} )
1685
1723
1686
1724
add_dependencies(${test_suite} ${test_name} )
1687
- get_target_property(test_suite_folder ${test_suite} FOLDER)
1688
- if (test_suite_folder)
1689
- set_property(TARGET ${test_name} PROPERTY FOLDER " ${test_suite_folder} ")
1690
- endif ()
1691
1725
endfunction()
1692
1726
1693
1727
# Use for test binaries that call llvm::getInputFileDirectory(). Use of this
@@ -1710,7 +1744,8 @@ function(add_benchmark benchmark_name)
1710
1744
add_llvm_executable(${benchmark_name} IGNORE_EXTERNALIZE_DEBUGINFO NO_INSTALL_RPATH ${ARGN} )
1711
1745
set(outdir ${CMAKE_CURRENT_BINARY_DIR} /${CMAKE_CFG_INTDIR} )
1712
1746
set_output_directory(${benchmark_name} BINARY_DIR ${outdir} LIBRARY_DIR ${outdir} )
1713
- set_property(TARGET ${benchmark_name} PROPERTY FOLDER " Utils ")
1747
+ get_subproject_title(subproject_title)
1748
+ set_property(TARGET ${benchmark_name} PROPERTY FOLDER " ${subproject_title} /Benchmarks ")
1714
1749
target_link_libraries(${benchmark_name} PRIVATE benchmark)
1715
1750
endfunction()
1716
1751
@@ -1999,6 +2034,8 @@ function(add_lit_target target comment)
1999
2034
COMMAND ${CMAKE_COMMAND} -E echo "${target} does nothing, no tools built." )
2000
2035
message (STATUS "${target} does nothing." )
2001
2036
endif ()
2037
+ get_subproject_title (subproject_title )
2038
+ set_target_properties (${target} PROPERTIES FOLDER "${subproject_title} /Tests" )
2002
2039
2003
2040
if (ARG_DEPENDS )
2004
2041
add_dependencies (${target} ${ARG_DEPENDS} )
@@ -2080,7 +2117,8 @@ function(add_lit_testsuites project directory)
2080
2117
cmake_parse_arguments (ARG "EXCLUDE_FROM_CHECK_ALL" "FOLDER" "PARAMS;DEPENDS;ARGS" ${ARGN} )
2081
2118
2082
2119
if (NOT ARG_FOLDER )
2083
- set (ARG_FOLDER "Test Subdirectories" )
2120
+ get_subproject_title (subproject_title )
2121
+ set (ARG_FOLDER "${subproject_title} /Tests/LIT Testsuites" )
2084
2122
endif ()
2085
2123
2086
2124
# Search recursively for test directories by assuming anything not
@@ -2282,7 +2320,8 @@ function(llvm_add_tool_symlink project link_name target)
2282
2320
set (should_build_all ALL )
2283
2321
endif ()
2284
2322
add_custom_target (${target_name} ${should_build_all} DEPENDS ${target} ${output_path} )
2285
- set_target_properties (${target_name} PROPERTIES FOLDER Tools )
2323
+ get_subproject_title (subproject_title )
2324
+ set_target_properties (${target_name} PROPERTIES FOLDER "${subproject_title} /Tools" )
2286
2325
2287
2326
# Make sure both the link and target are toolchain tools
2288
2327
if (${link_name} IN_LIST LLVM_TOOLCHAIN_TOOLS AND ${target} IN_LIST LLVM_TOOLCHAIN_TOOLS )
@@ -2542,5 +2581,7 @@ function(setup_host_tool tool_name setting_name exe_var_name target_var_name)
2542
2581
if (LLVM_USE_HOST_TOOLS AND NOT ${setting_name} )
2543
2582
build_native_tool (${tool_name} exe_name DEPENDS ${tool_name} )
2544
2583
add_custom_target (${target_var_name} DEPENDS ${exe_name} )
2584
+ get_subproject_title (subproject_title )
2585
+ set_target_properties (${target_var_name} PROPERTIES FOLDER "${subproject_title} /Native" )
2545
2586
endif ()
2546
2587
endfunction ()
0 commit comments