Index: llvm/CMakeLists.txt =================================================================== --- llvm/CMakeLists.txt +++ llvm/CMakeLists.txt @@ -1163,17 +1163,18 @@ add_subdirectory(lib) -if( LLVM_INCLUDE_UTILS ) +if( LLVM_INCLUDE_UTILS AND NOT LLVM_ENABLE_UTILS ) add_subdirectory(utils/FileCheck) add_subdirectory(utils/PerfectShuffle) add_subdirectory(utils/count) add_subdirectory(utils/not) add_subdirectory(utils/UnicodeData) add_subdirectory(utils/yaml-bench) - add_subdirectory(utils/split-file) - if( LLVM_INCLUDE_TESTS ) - add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest ${CMAKE_CURRENT_BINARY_DIR}/third-party/unittest) - endif() +elseif( LLVM_ENABLE_UTILS ) + # Build only specified utils from LLVM_ENABLE_UTILS + foreach(util ${LLVM_ENABLE_UTILS}) + add_subdirectory(utils/${util}) + endforeach() else() if ( LLVM_INCLUDE_TESTS ) message(FATAL_ERROR "Including tests when not building utils will not work. Index: llvm/docs/CMake.rst =================================================================== --- llvm/docs/CMake.rst +++ llvm/docs/CMake.rst @@ -302,6 +302,10 @@ enabled sub-projects. Nearly all of these variable names begin with ``LLVM_``. +**LLVM_ENABLE_LIBS**:STRING + Semicolon-separated list of libraries to build, or ignore this argument for + building all. + **BUILD_SHARED_LIBS**:BOOL Flag indicating if each LLVM component (e.g. Support) is built as a shared library (ON) or as a static library (OFF). Its default value is OFF. On @@ -393,6 +397,10 @@ the subdirectories of *unittests* for a complete list of unit tests.) It is possible to build all unit tests with the target *UnitTests*. +**LLVM_ENABLE_TOOLS**:STRING + Semicolon-separated list of tools to build, or ignore this argument for building + all. + **LLVM_BUILD_TOOLS**:BOOL Build LLVM tools. Defaults to ON. Targets for building each tool are generated in any case. You can build a tool separately by invoking its target. For @@ -656,6 +664,10 @@ If enabled, utility binaries like ``FileCheck`` and ``not`` will be installed to CMAKE_INSTALL_PREFIX. +**LLVM_ENABLE_UTILS**:STRING + Semicolon-separated list of utils to build, or ignore this argument for building + all. + **LLVM_INTEGRATED_CRT_ALLOC**:PATH On Windows, allows embedding a different C runtime allocator into the LLVM tools and libraries. Using a lock-free allocator such as the ones listed below Index: llvm/lib/CMakeLists.txt =================================================================== --- llvm/lib/CMakeLists.txt +++ llvm/lib/CMakeLists.txt @@ -3,49 +3,54 @@ # `Demangle', `Support' and `TableGen' libraries are added on the top-level # CMakeLists.txt -add_subdirectory(IR) -add_subdirectory(FuzzMutate) -add_subdirectory(FileCheck) -add_subdirectory(InterfaceStub) -add_subdirectory(IRPrinter) -add_subdirectory(IRReader) -add_subdirectory(CodeGen) -add_subdirectory(BinaryFormat) -add_subdirectory(Bitcode) -add_subdirectory(Bitstream) -add_subdirectory(DWARFLinker) -add_subdirectory(DWARFLinkerParallel) -add_subdirectory(Extensions) -add_subdirectory(Frontend) -add_subdirectory(Transforms) -add_subdirectory(Linker) -add_subdirectory(Analysis) -add_subdirectory(LTO) -add_subdirectory(MC) -add_subdirectory(MCA) -add_subdirectory(ObjCopy) -add_subdirectory(Object) -add_subdirectory(ObjectYAML) -add_subdirectory(Option) -add_subdirectory(Remarks) -add_subdirectory(Debuginfod) -add_subdirectory(DebugInfo) -add_subdirectory(DWP) -add_subdirectory(ExecutionEngine) -add_subdirectory(Target) -add_subdirectory(AsmParser) -add_subdirectory(LineEditor) -add_subdirectory(ProfileData) -add_subdirectory(Passes) -add_subdirectory(TargetParser) -add_subdirectory(TextAPI) -add_subdirectory(ToolDrivers) -add_subdirectory(XRay) +if(LLVM_ENABLE_LIBS) + # Build only specified libraries from LLVM_ENABLE_LIBS + foreach(lib ${LLVM_ENABLE_LIBS}) + add_subdirectory(${lib}) + endforeach() +else() + add_subdirectory(IR) + add_subdirectory(FuzzMutate) + add_subdirectory(FileCheck) + add_subdirectory(InterfaceStub) + add_subdirectory(IRReader) + add_subdirectory(CodeGen) + add_subdirectory(BinaryFormat) + add_subdirectory(Bitcode) + add_subdirectory(Bitstream) + add_subdirectory(DWARFLinker) + add_subdirectory(Extensions) + add_subdirectory(Frontend) + add_subdirectory(Transforms) + add_subdirectory(Linker) + add_subdirectory(Analysis) + add_subdirectory(LTO) + add_subdirectory(MC) + add_subdirectory(MCA) + add_subdirectory(ObjCopy) + add_subdirectory(Object) + add_subdirectory(ObjectYAML) + add_subdirectory(Option) + add_subdirectory(Remarks) + add_subdirectory(Debuginfod) + add_subdirectory(DebugInfo) + add_subdirectory(DWP) + add_subdirectory(ExecutionEngine) + add_subdirectory(Target) + add_subdirectory(AsmParser) + add_subdirectory(LineEditor) + add_subdirectory(ProfileData) + add_subdirectory(Passes) + add_subdirectory(TextAPI) + add_subdirectory(ToolDrivers) + add_subdirectory(XRay) + add_subdirectory(WindowsDriver) + add_subdirectory(WindowsManifest) +endif() + if (LLVM_INCLUDE_TESTS) add_subdirectory(Testing) endif() -add_subdirectory(WindowsDriver) -add_subdirectory(WindowsManifest) set(LLVMCONFIGLIBRARYDEPENDENCIESINC "${LLVM_BINARY_DIR}/tools/llvm-config/LibraryDependencies.inc") Index: llvm/tools/CMakeLists.txt =================================================================== --- llvm/tools/CMakeLists.txt +++ llvm/tools/CMakeLists.txt @@ -45,9 +45,16 @@ add_llvm_external_project(flang) add_llvm_external_project(bolt) -# Automatically add remaining sub-directories containing a 'CMakeLists.txt' -# file as external projects. -add_llvm_implicit_projects() +if(LLVM_ENABLE_TOOLS) + # Build only specified tools from LLVM_ENABLE_TOOLS + foreach(tool ${LLVM_ENABLE_TOOLS}) + add_llvm_tool_subdirectory(${tool}) + endforeach() +else() + # Automatically add remaining sub-directories containing a 'CMakeLists.txt' + # file as external projects. + add_llvm_implicit_projects() +endif() add_llvm_external_project(polly)