1cmake_minimum_required(VERSION 3.13.4) 2 3# Use old version of target_sources command which converts the source 4# file paths to full paths. 5cmake_policy(SET CMP0076 OLD) 6list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") 7 8# The top-level source directory of libc. 9set(LIBC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 10# The top-level directory in which libc is being built. 11set(LIBC_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) 12 13# Path libc/scripts directory. 14set(LIBC_BUILD_SCRIPTS_DIR "${LIBC_SOURCE_DIR}/utils/build_scripts") 15 16 17set(LIBC_TARGET_OS ${CMAKE_SYSTEM_NAME}) 18string(TOLOWER ${LIBC_TARGET_OS} LIBC_TARGET_OS) 19 20set(LIBC_TARGET_MACHINE ${CMAKE_SYSTEM_PROCESSOR}) 21 22option(LLVM_LIBC_ENABLE_LINTING "Enables linting of libc source files" ON) 23if(LLVM_LIBC_ENABLE_LINTING) 24 if("clang-tools-extra" IN_LIST LLVM_ENABLE_PROJECTS 25 AND "clang" IN_LIST LLVM_ENABLE_PROJECTS) 26 add_custom_target(lint-libc) 27 else() 28 message(FATAL_ERROR " 29 'clang' and 'clang-tools-extra' are required in LLVM_LIBC_ENABLE_PROJECTS to 30 lint llvm-libc. The linting step performs important checks to help prevent 31 the introduction of subtle bugs, but it may increase build times. 32 33 To disable linting set LLVM_LIBC_ENABLE_LINTING to OFF 34 (pass -DLLVM_LIBC_ENABLE_LINTING=OFF to cmake).") 35 endif() 36else() 37 message(WARNING " 38 Linting for libc is currently disabled. 39 40 This is not recommended, to enable set LLVM_LIBC_ENABLE_LINTING to ON 41 (pass -DLLVM_LIBC_ENABLE_LINTING=ON to cmake).") 42endif() 43 44include(CMakeParseArguments) 45include(LLVMLibCRules) 46include(LLVMLibCCheckCpuFeatures) 47 48add_subdirectory(include) 49add_subdirectory(config) 50add_subdirectory(src) 51add_subdirectory(utils) 52 53# The loader can potentially depend on the library components so add it 54# after the library implementation directories. 55add_subdirectory(loader) 56 57# The lib and test directories are added at the very end as tests 58# and libraries potentially draw from the components present in all 59# of the other directories. 60add_subdirectory(lib) 61if(LLVM_INCLUDE_TESTS) 62 add_subdirectory(test) 63 add_subdirectory(fuzzing) 64endif() 65