[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / cmake / caches / CrossWinToARMLinux.cmake
blob0c71b67304738aec36cab199766f0e182b81a228
1 # CrossWinToARMLinux.cmake
3 # Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
5 # This cache file can be used to build a cross toolchain to ARM Linux
6 # on Windows platform.
8 # NOTE: the build requires a development ARM Linux root filesystem to use
9 # proper target platform depended library and header files.
11 # Configure:
12 #  cmake -G Ninja ^
13 #       -DTOOLCHAIN_TARGET_TRIPLE=armv7-unknown-linux-gnueabihf ^
14 #       -DCMAKE_INSTALL_PREFIX=../install ^
15 #       -DDEFAULT_SYSROOT=<path-to-develop-arm-linux-root-fs> ^
16 #       -DLLVM_AR=<llvm_obj_root>/bin/llvm-ar[.exe] ^
17 #       -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
18 #       -DREMOTE_TEST_HOST="<hostname>" ^
19 #       -DREMOTE_TEST_USER="<ssh_user_name>" ^
20 #       -C<llvm_src_root>/llvm-project/clang/cmake/caches/CrossWinToARMLinux.cmake ^
21 #       <llvm_src_root>/llvm-project/llvm
22 # Build:
23 #  cmake --build . --target install
24 # Tests:
25 #  cmake --build . --target check-llvm
26 #  cmake --build . --target check-clang
27 #  cmake --build . --target check-lld
28 #  cmake --build . --target check-compiler-rt-<TOOLCHAIN_TARGET_TRIPLE>
29 #  cmake --build . --target check-cxxabi-<TOOLCHAIN_TARGET_TRIPLE>
30 #  cmake --build . --target check-unwind-<TOOLCHAIN_TARGET_TRIPLE>
31 #  cmake --build . --target check-cxx-<TOOLCHAIN_TARGET_TRIPLE>
33 # LLVM_PROJECT_DIR is the path to the llvm-project directory.
34 # The right way to compute it would probably be to use "${CMAKE_SOURCE_DIR}/../",
35 # but CMAKE_SOURCE_DIR is set to the wrong value on earlier CMake versions
36 # that we still need to support (for instance, 3.10.2).
37 get_filename_component(LLVM_PROJECT_DIR
38                        "${CMAKE_CURRENT_LIST_DIR}/../../../"
39                        ABSOLUTE)
41 if (NOT DEFINED DEFAULT_SYSROOT)
42   message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
43 endif()
45 if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
46   set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
47 endif()
48 if (NOT DEFINED LLVM_ENABLE_ASSERTIONS)
49   set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
50 endif()
51 if (NOT DEFINED LLVM_ENABLE_PROJECTS)
52   set(LLVM_ENABLE_PROJECTS "clang;clang-tools-extra;lld" CACHE STRING "")
53 endif()
54 if (NOT DEFINED LLVM_ENABLE_RUNTIMES)
55   set(LLVM_ENABLE_RUNTIMES "compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
56 endif()
58 if (NOT DEFINED TOOLCHAIN_TARGET_TRIPLE)
59   set(TOOLCHAIN_TARGET_TRIPLE "armv7-unknown-linux-gnueabihf")
60 else()
61   #NOTE: we must normalize specified target triple to a fully specified triple,
62   # including the vendor part. It is necessary to synchronize the runtime library
63   # installation path and operable target triple by Clang to get a correct runtime
64   # path through `-print-runtime-dir` Clang option.
65   string(REPLACE "-" ";" TOOLCHAIN_TARGET_TRIPLE "${TOOLCHAIN_TARGET_TRIPLE}")
66   list(LENGTH TOOLCHAIN_TARGET_TRIPLE TOOLCHAIN_TARGET_TRIPLE_LEN)
67   if (TOOLCHAIN_TARGET_TRIPLE_LEN LESS 3)
68     message(FATAL_ERROR "invalid target triple")
69   endif()
70   # We suppose missed vendor's part.
71   if (TOOLCHAIN_TARGET_TRIPLE_LEN LESS 4)
72     list(INSERT TOOLCHAIN_TARGET_TRIPLE 1 "unknown")
73   endif()
74   string(REPLACE ";" "-" TOOLCHAIN_TARGET_TRIPLE "${TOOLCHAIN_TARGET_TRIPLE}")
75 endif()
77 if (NOT DEFINED CMAKE_BUILD_TYPE)
78   set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
79 endif()
81 message(STATUS "Toolchain target triple: ${TOOLCHAIN_TARGET_TRIPLE}")
83 set(CMAKE_CROSSCOMPILING                    ON CACHE BOOL "")
84 set(CMAKE_CL_SHOWINCLUDES_PREFIX            "Note: including file: " CACHE STRING "")
85 # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
86 set(CMAKE_C_COMPILER_TARGET                 "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
87 set(CMAKE_CXX_COMPILER_TARGET               "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
89 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR      ON CACHE BOOL "")
90 set(LLVM_DEFAULT_TARGET_TRIPLE              "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
91 set(LLVM_TARGET_ARCH                        "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
92 set(LLVM_LIT_ARGS                           "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
94 set(CLANG_DEFAULT_LINKER                    "lld" CACHE STRING "")
96 if(WIN32)
97   set(CMAKE_MSVC_RUNTIME_LIBRARY            "MultiThreaded" CACHE STRING "")
98   set(LLVM_USE_CRT_RELEASE                  "MT" CACHE STRING "")
99 endif()
101 # Set up RPATH for the target runtime/builtin libraries.
102 # See some details here: https://reviews.llvm.org/D91099
103 if (NOT DEFINED RUNTIMES_INSTALL_RPATH)
104   set(RUNTIMES_INSTALL_RPATH                "\$ORIGIN/../lib;${CMAKE_INSTALL_PREFIX}/lib")
105 endif()
107 set(LLVM_BUILTIN_TARGETS                    "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
109 set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSTEM_NAME                         "Linux" CACHE STRING "")
110 set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSROOT                             "${DEFAULT_SYSROOT}"  CACHE STRING "")
111 set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_INSTALL_RPATH                       "${RUNTIMES_INSTALL_RPATH}"  CACHE STRING "")
112 set(BUILTINS_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_BUILD_WITH_INSTALL_RPATH            ON  CACHE BOOL "")
115 set(LLVM_RUNTIME_TARGETS                    "${TOOLCHAIN_TARGET_TRIPLE}" CACHE STRING "")
117 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LLVM_ENABLE_RUNTIMES                      "${LLVM_ENABLE_RUNTIMES}" CACHE STRING "")
119 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSTEM_NAME                         "Linux" CACHE STRING "")
120 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_SYSROOT                             "${DEFAULT_SYSROOT}"  CACHE STRING "")
121 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_INSTALL_RPATH                       "${RUNTIMES_INSTALL_RPATH}"  CACHE STRING "")
122 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_CMAKE_BUILD_WITH_INSTALL_RPATH            ON  CACHE BOOL "")
124 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_BUILTINS                ON CACHE BOOL "")
125 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_SANITIZERS              OFF CACHE BOOL "")
126 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_XRAY                    OFF CACHE BOOL "")
127 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_LIBFUZZER               OFF CACHE BOOL "")
128 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_PROFILE                 OFF CACHE BOOL "")
129 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_CRT                     OFF CACHE BOOL "")
130 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_BUILD_ORC                     OFF CACHE BOOL "")
131 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_DEFAULT_TARGET_ONLY           ON CACHE BOOL "")
132 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_INCLUDE_TESTS                 ON CACHE BOOL "")
133 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_CAN_EXECUTE_TESTS             ON CACHE BOOL "")
135 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_USE_BUILTINS_LIBRARY          ON CACHE BOOL "")
137 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_USE_COMPILER_RT                 ON CACHE BOOL "")
138 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_ENABLE_SHARED                   OFF CACHE BOOL "")
140 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_LLVM_UNWINDER               ON CACHE BOOL "")
141 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_STATIC_UNWINDER          ON CACHE BOOL "")
142 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_USE_COMPILER_RT                 ON CACHE BOOL "")
143 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS   OFF CACHE BOOL "")
144 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXXABI OFF CACHE BOOL "")
145 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX   OFF CACHE BOOL "")
146 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_ENABLE_SHARED                   OFF CACHE BOOL "")
148 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXXABI   OFF CACHE BOOL "")
149 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_LINK_TESTS_WITH_SHARED_LIBCXX      OFF CACHE BOOL "")
151 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_USE_COMPILER_RT                    ON CACHE BOOL "")
152 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_SHARED                      OFF CACHE BOOL "")
153 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ABI_VERSION                        2 CACHE STRING "")
154 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_CXX_ABI                            "libcxxabi" CACHE STRING "")    #!!!
155 set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS      ON CACHE BOOL "")
158 find_package(Python3 COMPONENTS Interpreter)
160 # Remote test configuration.
161 if(DEFINED REMOTE_TEST_HOST)
162   # Allow override with the custom values.
163   if(NOT DEFINED DEFAULT_TEST_EXECUTOR)
164     set(DEFAULT_TEST_EXECUTOR                 "\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/libcxx/utils/ssh.py\\\" --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}")
165   endif()
166   if(NOT DEFINED DEFAULT_TEST_TARGET_INFO)
167     set(DEFAULT_TEST_TARGET_INFO              "libcxx.test.target_info.LinuxRemoteTI")
168   endif()
170   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_COMPILER_RT_EMULATOR
171         "\\\"${Python3_EXECUTABLE}\\\" \\\"${LLVM_PROJECT_DIR}/llvm/utils/remote-exec.py\\\" --execdir %%T --exec-pattern='.*\\.c.*\\.tmp.*' --host=${REMOTE_TEST_USER}@${REMOTE_TEST_HOST}"
172         CACHE STRING "")
174   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_TARGET_INFO                   "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
175   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBUNWIND_EXECUTOR                      "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
177   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_TARGET_INFO                   "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
178   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXXABI_EXECUTOR                      "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
179   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_TARGET_INFO                      "${DEFAULT_TEST_TARGET_INFO}" CACHE STRING "")
180   set(RUNTIMES_${TOOLCHAIN_TARGET_TRIPLE}_LIBCXX_EXECUTOR                         "${DEFAULT_TEST_EXECUTOR}" CACHE STRING "")
181 endif()
183 set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
184 set(LLVM_TOOLCHAIN_TOOLS
185   llvm-ar
186   llvm-cov
187   llvm-cxxfilt
188   llvm-dwarfdump
189   llvm-lib
190   llvm-nm
191   llvm-objdump
192   llvm-pdbutil
193   llvm-profdata
194   llvm-ranlib
195   llvm-readobj
196   llvm-size
197   llvm-symbolizer
198   CACHE STRING "")
200 set(LLVM_DISTRIBUTION_COMPONENTS
201   clang
202   lld
203   LTO
204   clang-format
205   builtins
206   runtimes
207   ${LLVM_TOOLCHAIN_TOOLS}
208   CACHE STRING "")