[Driver] Remove ignored Flag form of -fauto-profile/-fprofile-sample-use
[llvm-project.git] / lldb / cmake / modules / LLDBStandalone.cmake
blobc9367214848fda72030970ea98167c1d1354989b
1 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
2   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
3 endif()
5 list(APPEND CMAKE_MODULE_PATH "${LLVM_COMMON_CMAKE_UTILS}/Modules")
7 option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
9 find_package(LLVM REQUIRED CONFIG HINTS ${LLVM_DIR} NO_CMAKE_FIND_ROOT_PATH)
10 find_package(Clang REQUIRED CONFIG HINTS ${Clang_DIR} ${LLVM_DIR}/../clang NO_CMAKE_FIND_ROOT_PATH)
12 # We set LLVM_CMAKE_DIR so that GetSVN.cmake is found correctly when building SVNVersion.inc
13 set(LLVM_CMAKE_DIR ${LLVM_CMAKE_DIR} CACHE PATH "Path to LLVM CMake modules")
15 set(LLVM_MAIN_SRC_DIR ${LLVM_BUILD_MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
16 set(LLVM_MAIN_INCLUDE_DIR ${LLVM_MAIN_INCLUDE_DIR} CACHE PATH "Path to llvm/include")
17 set(LLVM_BINARY_DIR ${LLVM_BINARY_DIR} CACHE PATH "Path to LLVM build tree")
19 set(LLDB_TEST_LIBCXX_ROOT_DIR "${LLVM_BINARY_DIR}" CACHE PATH
20     "The build root for libcxx. Used in standalone builds to point the API tests to a custom build of libcxx.")
22 set(LLVM_LIT_ARGS "-sv" CACHE STRING "Default options for lit")
24 set(lit_file_name "llvm-lit")
25 if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
26   set(lit_file_name "${lit_file_name}.py")
27 endif()
29 function(append_configuration_directories input_dir output_dirs)
30   set(dirs_list ${input_dir})
31   foreach(config_type ${LLVM_CONFIGURATION_TYPES})
32     string(REPLACE ${CMAKE_CFG_INTDIR} ${config_type} dir ${input_dir})
33     list(APPEND dirs_list ${dir})
34   endforeach()
35   set(${output_dirs} ${dirs_list} PARENT_SCOPE)
36 endfunction()
39 append_configuration_directories(${LLVM_TOOLS_BINARY_DIR} config_dirs)
40 find_program(lit_full_path ${lit_file_name} ${config_dirs} NO_DEFAULT_PATH)
41 set(LLVM_DEFAULT_EXTERNAL_LIT ${lit_full_path} CACHE PATH "Path to llvm-lit")
43 if(LLVM_TABLEGEN)
44   set(LLVM_TABLEGEN_EXE ${LLVM_TABLEGEN})
45 else()
46   if(CMAKE_CROSSCOMPILING)
47     set(LLVM_NATIVE_BUILD "${LLVM_BINARY_DIR}/NATIVE")
48     if (NOT EXISTS "${LLVM_NATIVE_BUILD}")
49       message(FATAL_ERROR
50         "Attempting to cross-compile LLDB standalone but no native LLVM build
51         found. Please cross-compile LLVM as well.")
52     endif()
54     if (CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
55       set(HOST_EXECUTABLE_SUFFIX ".exe")
56     endif()
58     if (NOT CMAKE_CONFIGURATION_TYPES)
59       set(LLVM_TABLEGEN_EXE
60         "${LLVM_NATIVE_BUILD}/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
61     else()
62       # NOTE: LLVM NATIVE build is always built Release, as is specified in
63       # CrossCompile.cmake
64       set(LLVM_TABLEGEN_EXE
65         "${LLVM_NATIVE_BUILD}/Release/bin/llvm-tblgen${HOST_EXECUTABLE_SUFFIX}")
66     endif()
67   else()
68     set(tblgen_file_name "llvm-tblgen${CMAKE_EXECUTABLE_SUFFIX}")
69     append_configuration_directories(${LLVM_TOOLS_BINARY_DIR} config_dirs)
70     find_program(LLVM_TABLEGEN_EXE ${tblgen_file_name} ${config_dirs} NO_DEFAULT_PATH)
71   endif()
72 endif()
74 # They are used as destination of target generators.
75 set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
76 set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
77 if(WIN32 OR CYGWIN)
78   # DLL platform -- put DLLs into bin.
79   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
80 else()
81   set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
82 endif()
84 # We append the directory in which LLVMConfig.cmake lives. We expect LLVM's
85 # CMake modules to be in that directory as well.
86 list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
88 include(AddLLVM)
89 include(TableGen)
90 include(HandleLLVMOptions)
91 include(CheckAtomic)
92 include(LLVMDistributionSupport)
94 set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
96 set(CMAKE_INCLUDE_CURRENT_DIR ON)
97 include_directories(
98   "${CMAKE_BINARY_DIR}/include"
99   "${LLVM_INCLUDE_DIRS}"
100   "${CLANG_INCLUDE_DIRS}")
102 if(LLDB_INCLUDE_TESTS)
103   # Build the gtest library needed for unittests, if we have LLVM sources
104   # handy.
105   if (EXISTS ${LLVM_THIRD_PARTY_DIR}/unittest AND NOT TARGET llvm_gtest)
106     add_subdirectory(${LLVM_THIRD_PARTY_DIR}/unittest third-party/unittest)
107   endif()
108   # LLVMTestingSupport library is needed for Process/gdb-remote.
109   if (EXISTS ${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
110       AND NOT TARGET LLVMTestingSupport)
111     add_subdirectory(${LLVM_MAIN_SRC_DIR}/lib/Testing/Support
112       lib/Testing/Support)
113   endif()
114 endif()
116 option(LLVM_USE_FOLDERS "Enable solution folders in Visual Studio. Disable for Express versions." ON)
117 if(LLVM_USE_FOLDERS)
118   set_property(GLOBAL PROPERTY USE_FOLDERS ON)
119 endif()
121 set_target_properties(clang-tablegen-targets PROPERTIES FOLDER "Clang/Tablegenning")
122 set_target_properties(intrinsics_gen PROPERTIES FOLDER "LLVM/Tablegenning")
124 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
125   set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
126 endif()
128 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
129 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
130 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
132 # If LLDB is building against a prebuilt Clang, then the Clang resource
133 # directory that LLDB is using for its embedded Clang instance needs to point to
134 # the resource directory of the used Clang installation.
135 if (NOT TARGET clang-resource-headers)
136   include(GetClangResourceDir)
137   get_clang_resource_dir(LLDB_EXTERNAL_CLANG_RESOURCE_DIR
138     PREFIX "${Clang_DIR}/../../../")
140   if (NOT EXISTS ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR})
141     message(FATAL_ERROR "Expected directory for clang-resource-headers not found: ${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}")
142   endif()
143 endif()